Forum: Ruby on Rails Getting Started

Posted by rabinprithvi (Guest)
on 2012-09-22 13:20
(Received via mailing list)
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'
Posted by Fabian Becker (Guest)
on 2012-09-22 14:04
(Received via mailing list)
Because by default the show_path is used for a model if you hand it to 
the
link_to helper.

On Sat, Sep 22, 2012 at 1:19 PM, rabinprithvi <
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.