【发布时间】:2023-03-12 01:02:01
【问题描述】:
我的 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]
任何想法我错过了什么?我知道这很容易,但我现在没有想法。我应该在我的控制器中的哪里添加这个调用?
【问题讨论】:
标签: ruby-on-rails comments associations acts-as-commentable