0

searchlogic を使用していたときは、次のように使用できました。

27 #      @todos = Todo.contact_user_id_is(current_user).
 28 #                    contact_campaign_id_is(@campaign).
 29 #                    current_date_lte(Date.today).
 30 #                    done_date_null.
 31 #                    ascend_by_contact_id.
 32 #                    ascend_by_current_date

たとえば、Todo レコードに属する連絡先に属するキャンペーンを検索できます。

これは私が試したものです(ソートの方法がわからない:

 22       @todos = Todo.joins(:contacts).where(:user_id.eq => current_user,
 23                           :contacts => { :campaign_id.eq => @campaign.id},
 24                           :current_date.lteq => Date.today,
 25                           :done_date.not_eq => nil)

metawhere でそのようなことを行うにはどうすればよいですか?

4

1 に答える 1

0

上記の Searchlogic クエリに基づいたケースであると私が推測している Todo belongs_to または has_one contact の場合、次のようなことを行う必要があります (未テスト):

@todos = Todo.joins(:contact).
              where(
                :contact => {
                  :user_id => current_user.id,
                  :campaign_id => @campaign.id
                },
                :current_date.lteq => Date.today,
                :done_date.not_eq => nil
              ).
              order(:contact_id, :current_date)
于 2011-06-02T12:47:52.277 に答える