Passing parameters to custom RESTful routes in Rails (using :collection)
        Posted  
        
            by dwhite
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by dwhite
        
        
        
        Published on 2010-04-11T02:17:55Z
        Indexed on 
            2010/04/11
            2:23 UTC
        
        
        Read the original article
        Hit count: 389
        
ruby-on-rails
|routing
I am trying to add a custom route to my RESTful routes using the :collection param on map.resources like so:
map.resources :products, :collection => { :tagged => :get }
The tagged action takes in a :tag parameter.  I am able to link to the URL route using:
tagged_products_path(:tag => tag.name).  My issue with this is that the URL that this generates:
/products/tagged?tag=electronic
I would like the tag to be in the URL and not the tag, like so:
/products/tagged/electronic
Of course this can be accomplished by a separate named route, but I'm wondering if I'm missing something and there is a way to do this with the :collection hash.
Thanks in advance for your help
-Damien
© Stack Overflow or respective owner