Ruby on rails RubyonRails入门-脚手架

Ruby on rails RubyonRails入门-脚手架,ruby-on-rails,scaffolding,Ruby On Rails,Scaffolding,我不熟悉rails 当我为用户生成scaffold时,在products/index.html中我有以下代码 <h1>Listing users</h1> <table> <tr> <th>Name</th> </tr> <% @users.each do |user| %> <tr> <td><%=h user.name %><

我不熟悉rails

当我为用户生成scaffold时,在products/index.html中我有以下代码

<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 %>
列出用户
名称
“你确定吗?”,:method=>:delete%>

------------------------------------------------------------------------------------------------------------------------------- 我怀疑的是标签的链接,
为什么不显示用户路径(用户)?对于第一个链接“Show”
任何帮助都会被告知

显示用户路径会起作用,只是更详细而已


欢迎来到Ruby on Rails的神奇之处。

在生成支架时,您创建了资源“用户”,这就是为什么您可以在
链接中按原样使用它。
:Rails知道您想要查看资源用户。
show\u user\u path(user)
直接链接到控制器show action

这是Ruby on Rails中的惯例,您也可以使用
show\u user\u path(user)