I\'m using Rails 3 with Devise for user auth. Let\'s say I have a User model, with Devise enabled, and a Product model, and that a User has_many Products.
In my Products
You could add a class method on Product with the user sent as an argument.
class Product < ActiveRecord::Base
...
def self.for_user(user)
user.admin? ? where({}) : where(:owner_id => user.id)
end
Then you can call it like this:
Product.for_user(current_user).find(params[:id])
PS: There's probably a better way to do the where({})
.