Reputation: 343
I have a 10 products but I want particular product default on display. Example If type http://localhost/products then product display should be product xyz.
Thanks,
Upvotes: 0
Views: 49
Reputation: 42863
It looks like you are using REST so in your products controller:
def index
@products = []
@products << p1 = Product.find_by_name('name')
@products << p2 = Product.find_by_name('name')
@products << p3 = Product.find_by_name('name')
end
Upvotes: 0
Reputation: 1956
I'd create a new boolean column like :default_product, then in the model use a scope like "scope :feature_product, first(:conditions => {:default_product => true})". Then, in the controller, use :feature_product to instead of all by doing Product.feature_product in the index method.
Upvotes: 2