0

I want to show photos with categories from 1-9, but NOT show photos with category 15.

I tried:

scope :no_landing, ->  {where(category_id: [1,2,3,4,5,6,7,8,9])}

But there has to be a more efficient way.

Any ideas?

Thanks guys!

Gibson
  • 2,055
  • 2
  • 23
  • 48
  • 2
    `where.not(category_id: 15)` – RocketR Dec 29 '14 at 22:23
  • possible duplicate of [Rails ActiveRecord: Find All Users Except Current User](http://stackoverflow.com/questions/2672744/rails-activerecord-find-all-users-except-current-user/17560591#17560591) – Mohamad Dec 29 '14 at 22:24
  • To add to @RocketR, you want to pass an id to the scope: `scope :no_landing, ->(id) { where.not(category_id: id) }` [Check this answer](http://stackoverflow.com/questions/2672744/rails-activerecord-find-all-users-except-current-user/17560591#17560591) out for more details. – Mohamad Dec 29 '14 at 22:30

0 Answers0