我的 Rails 应用程序中有一个非常简单的评论系统——我想允许用户点击评论者的名字来访问他的个人资料。
但没有任何成功 - 我不确定我错过了什么。
<% @comments.each do |comment| %>
<p><a href="<%= user_path(@comment.user_id) %>" style="text-decoration : none"><%= image_tag comment.user.image, class: "img-circle", width: "30x30" if comment.user %><font class="small" color="#28c3ab"> @<%= comment.user.name if comment.user %></font></a>
<% end %>
但是我没有路由匹配错误:
No route matches {:action=>"show", :controller=>"users", :id=>nil} missing required keys: [:id]
有什么我想念的想法吗?我知道这很容易,但我现在没有想法。我应该在我的控制器中的哪里添加这个调用?