0
使用框架的結果,我需要2個ActiveRecord的範圍:呼叫來電呼叫
scope :tagged_with, lambda { |tag| {:conditions => [" tags like ? ", "% #{tag} %"] } }
scope :tagged_with_any, lambda { |tag_array | [HERE NEW IMPLEMENTATION] }
我想第二個範圍是基於第一個範圍。如果你會做硬編碼,你會爲一個2元素的數組做:
lambda { | tag_array | tagged_with(tag_array[0]).tagged_with(tag_array[1]) }
其作品,但我怎麼做通用
lambda { | tag_array | tags.each { |t| tagged_with(t) } }
顯然不會做的工作。
你究竟想要什麼? 「tagged_with_any」表示ANY,但範圍的連接表示ALL。 – tokland 2011-02-12 13:42:09
任何對我而言意味着'a或b或c是真的' – Beffa 2011-02-12 14:05:59