Search Results

Search found 1 results on 1 pages for 'kibyegon'.

Page 1/1 | 1 

  • How do I use a named_scope to filter records in my model

    - by kibyegon
    I have a model "Product" with a "description" field. Now I want to have a link in the index page that when clicked will show all products where the description is blank (empty). In the model I have defined a named_scope like this named_scope :no_description, :conditions => { :description => "" } I have checked that the named_scope works by calling Product.no_description.count on the console. As far as I know, the controller is then supposed to handle the filter request from the link on the "index" action but be able to distinguish it from the default which is view all products. def index @products = Product.all ... My problem is getting the controller handle the different request, what route to setup for the link on the view and the actual link on the view. Hope I explained my problem.

    Read the article

1