Getting Started

10 views
Skip to first unread message

rabinprithvi

unread,
Sep 22, 2012, 7:19:33 AM9/22/12
to rubyonra...@googlegroups.com
I am new to rails.

When I generate scaffold for products , in products/index.html i have this code

<h1>Listing users</h1>

<table>
  <tr>
    <th>Name</th>
  </tr>

<% @users.each do |user| %>
  <tr>
    <td><%=h user.name %></td>
    <td><%= link_to 'Show', user %></td>
    <td><%= link_to 'Edit', edit_user_path(user) %></td>
    <td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New user', new_user_path %>

-------------------------------------------------------------------------------------------------------------------------------

My doubt is in link_to tags,

<%= link_to 'Show', user %>
<%= link_to 'Edit', edit_user_path(user) %>
<%= link_to 'New user', new_user_path %>


Why not show_user_path(user) ? for first link 'Show'



Fabian Becker

unread,
Sep 22, 2012, 8:03:20 AM9/22/12
to rubyonra...@googlegroups.com
Because by default the show_path is used for a model if you hand it to the link_to helper.





--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/nSRQKGpTuGAJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages