Rajdeep Singh
Rajdeep Singh

Reputation: 17834

Showing all the products except the current_user?

I want to see all the products in the products table except those products which belongs to the current_user:

products_controller.rb

def index
    @products = Product.all
end

routes.rb

resources :users do
    resources :products
end

Upvotes: 0

Views: 62

Answers (1)

Sagar.Patil
Sagar.Patil

Reputation: 991

Product.where('user_id<>?',current_user.id)

Upvotes: 1

Related Questions