0
我想顯示current_user帖子和用戶,他或她是在單個視圖後的帖子。無論出於何種原因,我已經創建的帖子都沒有加載到視圖中。數據庫中目前有5個。結合當前的用戶帖子和追隨者的帖子瓦特/ Acts_as_Follower Rails 4
供應控制
def feed
following_ids = current_user.following_users.map(&:id)
@following_activities = Post.where('user_id in (?)', following_ids.push).order('created_at desc').paginate(page: params[:page])
end
feed.html.erb
<% if @following_activities.any? %>
<% @following_activities.each do |user| %>
<%= link_to(image_tag(user.post.avatar.url(:thumb), style: 'text-decoration: none;', class: 'round-image'), user_path(user)) %>
<%= user.post.username %>
<%= user.post.body %>
<%= image_tag(user.post.photo.url(:medium), style: '') %>
<% end %>
<% else %>
<h1>No new posts</h1>
<% end %>
它現在說#undefined方法'頭像'#當我使用您的查詢方法。有什麼線索爲什麼? –