tiny update -
scope :recommended, -> { where(self.recommended_condition) }
def recommended?
eval(self.class.recommended_condition("||"))
end
def self.recommended_condition(selector == "OR")
'editors_selection #{selector} rating > 9'
end
On Tue, Sep 16, 2014 at 1:33 PM, Vivek Sampara
wrot
scope :recommended, -> { where(recommended_condition) }
def recommended?
eval(recommended_condition("||"))
end
def recommended_condition(selector = "OR")
"editors_selection #{selector} rating > 9"
end
On Tue, Sep 16, 2014 at 7:33 AM, wrote:
> Consider something like that in a model:
>
> s
Consider something like that in a model:
scope :recommended, -> { where('editors_selection OR rating > 9') }
def recommended?
editors_selection? || rating > 9
end
How to DRY it up?
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To u
3 matches
Mail list logo