Q:

Writing a method to not show private resource unless it's current users?

I have my Product model that has the attribute private. I want to make a method that allows the current user to be able to select their private products and others that are  private = false only. 
class Product < ActiveRecord::Base
  attr_accessible :name, :private
  belongs_to :user

  def permission
    unless self.current_user
      unless self.private
      end
    end
  end
end

Does it start out like this? How would I write this method? The goal is to put this inside of a select menu.

A:

I would create a class method for this which you would pass something like current_user to
class Product < ActiveRecord::Base
  attr_accessible :name, :private
  belongs_to :user

  def self.for_user_or_public(user)
    where("user_id = ? or private = ?", user.id, false)
  end
end

Usage:
products = Product.for_user_or_public(current_user)

As for the select, something like the following should work
<%= f.collection_select :owner_id, Product.for_user_or_public(current_user), :user_id, :name, { :include_blank => true } %>

