I am reading Rails 3 in action. The book creates a class of projects that has_many :tickets
and a class of tickets that belongs_to :project
. The route.rb file looks like this:
resources :projects do resources :tickets end
Now the form for creating a ticket accepts such an array:
<%= form_for [@project, @ticket] do |f| %>
And on the ticket page show.html.erb there are links that look like this:
<%= link_to "Edit Ticket", [:edit, @project, @ticket] %> <%= link_to "Delete Ticket", [@project, @ticket], :method => :delete, :confirm => "Are you sure you want to delete this ticket?" %>
Now I'm confused why an array of two objects needs to be passed to form_for () and link_to (). In addition, why do you need to "Edit ticket" and: edit the symbol, and "Delete ticket" is not required: destroy the symbol.
thank you microphone
source share