fey-Zo74MKda82iq+yG4GVM+lgC/G2K4zDHf@public.gmane.org
2014-Sep-16 02:03 UTC
Logic duplication in scopes & predicates
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 unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/86dabc42-3b35-4cbe-ae55-032a371276e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.