concept edit action in category rails

appears as: edit action, The edit action, edit actions, n edit action
Rails 4 in Action: Revised Edition of Rails 3 in Action

This is an excerpt from Manning's book Rails 4 in Action: Revised Edition of Rails 3 in Action.

Listing 1.14. The edit action of PurchasesController
def edit end

For this action, you’re working with a preexisting object rather than a new object, which you used in the new action. This preexisting object is found by the edit action in PurchasesController, as shown here.

Listing 1.14. The edit action of PurchasesController
def edit end

This version of simple_form_for, with an array argument, indicates that you want the form to post to a nested route. For the new action, this generates a route like /projects/1/tickets, and for the edit action, it generates a route like /projects/1/tickets/2. This type of routing is known as polymorphic routing.

5.3.2. Adding the edit action

The next logical step is to define the edit action in your TicketsController. Like the edit action in ProjectsController, technically it doesn’t need to exist because it will be empty—all it needs to do is load the @project and @ticket variables, which are already done via set_project and set_ticket. But it’s good practice to define it, so add it in under the show action in TicketsController, but before the private call.

Rails 3 in Action

This is an excerpt from Manning's book Rails 3 in Action.

For this action, you’re working with a pre-existing object rather than a new object, which you used in new. This pre-existing object is found by the edit action in PurchasesController, shown in the next listing.

This code indicates to form_for that you want the form to post to the nested route you’re using. For the new action, this generate a route like /projects/1/tickets, and for the edit action, it generates a route like /projects/1/tickets/2. When you run bin/cucumber features/creating_tickets.feature again, you’re told the create action is missing:

5.3.1. Adding the edit action

The next logical step is to define the edit action in your TicketsController, which you can leave empty because the find_ticket before filter does all the hard lifting for you (shown in the following listing).