【发布时间】:2016-07-14 16:28:22
【问题描述】:
我现在正在构建一个基本的基本社交媒体应用程序。
我有一个用户类和一个状态类。
对于每个状态,都有一个“创建者”(用户对象)和一个“主题”(该状态所涉及的用户对象)。我能够使用acts_as_taggable_on gem 创建标签。最终发生的是当用户去创建帖子时,他/她可以从下拉菜单中选择另一个用户。然后存储所选用户的 id 属性。
现在我正在尝试链接到所选用户的个人资料。这是我在个人资料页面上显示状态的代码。
<% if @statuses %>
<% @statuses.each do |status| %>
<div class="well">
<%= status.content %>
<br></br>
#link to user who's associated with the tagId
<%= link_to User.find(status.tag_list).profile_name, user_profile_path(User.find(status.tag_list).profile_name) %>
<hr />
<%= link_to time_ago_in_words(status.created_at), status_path(status) %> ago
</div>
<% end %>
<% end%>
这是上面代码中断的那一行
<%= link_to User.find(status.tag_list).profile_name, user_profile_path(User.find(status.tag_list).profile_name) %>
谁能帮我解决这个问题?
【问题讨论】:
-
定义“代码中断”
-
贴出错误信息很有帮助
标签: ruby-on-rails ruby attributes associations ruby-on-rails-5