@people = People.scoped
@people = @people.where(...) if ...
@people = @people.where(...) if ...
@people = @people.where(...) if ...
@people = @people.where(...) if ...
をリファクタリング支援する任意のルビー既存のソリューションは私はルビー次のコード
@people = People.scoped
@people.???? do
where(...) if ...
where(...) if ...
where(...) if ...
end
PSのようなものを作ることです:答えてくれてありがとう。しかし、あなたが提供するソリューションは次のようになります
def self.conditional_scope
where(...) if ...
where(...) if ...
where(...) if ...
end
"if"がすべて真であっても最後になると思います。
私は正しいですか?
もう一度同意したようです。 +1 :) – apneadiving
この解決方法は最後に戻ります。私は連鎖が必要です。私は正しい? – randx
@randx、回答を更新しました – fl00r