0
如何合併這兩個ActiveRecord關係?結合兩處查詢
activity1 = PublicActivity::Activity.where("user_recipients LIKE ':id,%' or user_recipients LIKE '%, :id' or user_recipients LIKE '%, :id,%' or user_recipients = ':id'", id: current_user.id)
activity2 = PublicActivity::Activity.where(recipient_id: current_user.id, recipient_type: 'User')
當我做到這一點,如果是空的,他們默認爲空單
@activity = activity1.merge(activity2)
你的意思是鏈接'where'查詢? – Pavan
[組合兩個ActiveRecord :: Relation對象]的可能重複(http://stackoverflow.com/questions/9540801/combine-two-activerecordrelation-objects) – Drenmi