我有以下模式。
class Post < ActiveRecord::Base
has_many :timeline_items, :as=>:subject
define_index do
....?
end
end
class TimelineItem < ActiveRecord::Base
belongs_to :subject, :polymorphic=>true
belongs_to :actor, :polymorphic=>:true
end
我想让属于特定行为者的所有职位都思考。
在<条码>中 我愿意这样做。
Post. where (temporal_items.actor_type = “User” and time_items.actor_id IN [1,2,3].includes(:timeline_items)
我的问题是,必须确定哪些指数,以及必须用什么方法得出同样的结果?
Update
However I also need to filter the posts by different actor types like:
Post.where( timeline_items.actor_type = "Group" AND timeline_items.actor_id IN [1,2,3]).includes(:timeline_items)