我试图让基于 public_activity gem 的通知控制器显示用户的活动以及他关注的活动。
我让它显示用户关注的活动,但我似乎无法让用户自己的活动被包括在内。
换句话说,这有效:
class NotificationsController < CooperativeController
before_filter :authenticate_user!
def index
@activities = PublicActivity::Activity.where(:owner_id => current_user.following_users, :owner_type => 'User').order('created_at DESC')
end
end
虽然这不是:
class NotificationsController < CooperativeController
before_filter :authenticate_user!
def index
notify_user_of = current_user.following_users
notify_user_of << current_user
@activities = PublicActivity::Activity.where(:owner_id => notify_user_of, :owner_type => 'User').order('created_at DESC')
end
end