Rails Views [confused by guide] -
i've been confused next lines:
<td><%= link_to 'show', book %></td> <td><%= link_to 'edit', edit_book_path(book) %></td> <td><%= link_to 'remove', book, :confirm => 'are sure?', :method => :delete %></td> from
http://guides.rubyonrails.org/layouts_and_rendering.html what 'edit_book_path(book)' defined? can perchance explain means? @ controller 'book' , check controller method 'edit' while passing in variable book?
what <%= link_to 'show', book %>? go controller method 'show'? or display 'show'? 'book' passed on variable?
1) <%= link_to 'show', book %> # => <a href="/resource/show/1">show</a>
this means show link , path of link book show. if click on show, corresponding book shown.
here book has id of 1. book id = 1 displayed.
example:
link_to "profile", :controller => "profiles", :action => "show", :id => @profile # => <a href="/profiles/show/1">profile</a> similarly,
link_to "profiles", profiles_path # => <a href="/profiles">profiles</a> the above link have profiles link , path profiles path.
2) <td><%= link_to 'edit', edit_book_path(book) %></td> #=> <a href="/book/1/edit">edit</a> this means edit link , path of link book edit. if click on edit, corresponding book page displayed edit.
3) <td><%= link_to 'remove', book, :confirm => 'are sure?', :method => :delete %></td> #=> <a href=book rel="nofollow" data-method="delete" data-confirm="are sure?">remove</a> this means remove link , path of link book remove. if click on remove, corresponding book page removed , not shown in view.
ruby-on-rails ruby-on-rails-3
No comments:
Post a Comment