Guest User

Untitled

a guest
Apr 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. # Ever had the trouble to create a new named_scope out of others? See how it works:
  2. class Fu < ActiveRecord::Base
  3. named_scope :has_moo, :conditions => { :moo => true }
  4. named_scope :has_foo, :conditions => { :foo => true }
  5.  
  6. def has_moo_and_foo
  7. has_moo.has_foo
  8. end
  9.  
  10. end
  11.  
  12. # -> now this works:
  13. # Fu.has_moo_and_foo.all
  14.  
  15. # Sweet!
Add Comment
Please, Sign In to add comment