SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @places = Place.find(:all, :include => :categories, :conditions => { "categories_places.category_id" => id})
  2.      
  3. some_array_of_ids = [1, 2, 3]
  4. @places = Place.find(:all, :include => :categories, :conditions => ['categories.id IN (?)', some_array_of_ids)
  5.      
  6. @places = Place.find(:all, :include => :categories, :conditions => ["categories_places.category_id IN ?", int])
  7.      
  8. some_array_of_ids = [1,2,3]
  9. @places = Place.includes(:categories).where('categories.id IN (?)', some_array_of_ids)
  10.      
  11. some_array_of_ids = [1,2,3]
  12. @places = Place.joins(:categories).where('categories.id': some_array_of_ids)
  13.      
  14. scope :by_categories, ->(category_ids) { joins(:categories).where('categories.id': category_ids) }
  15.      
  16. some_array_of_ids = [1,2,3]
  17. @places = Place.by_categories(some_array_of_ids)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top