In my Product model I’m trying to make a scope that doesn’t show the current users products.
class Product < ActiveRecord::Base
def self.not_current_users_products
where(:user_id => current_user == nil)
end
end
This should look at the current user and see if the products belong to him or not.
How would I do this?
While there are some hacks out there to make
current_useravailable to your models, it isn’t by default. You could set up the method to be a little more generic, then pass in your current_user:Then call it with: