Just wondering if this is possible and how to configure routes.rb Let''s say in routes.rb I have: map.resources :products this would allow me to use: new_product_path and the url would be /product/new edit_product_path and the url would be /product/1/edit I would like to add another method to the controller that would be exactly like the "new" method. my_method_product_path and the url would be /product/my_method I tried: map.resources :products, :member => { :my_method => :get} but, the method wants a parameter like my_method_product_path(0) How would I configure the routes.rb to accomplish this task?? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
can you give us more information on what this action is supposed to do? On Jan 24, 2008 10:04 AM, TheDuckman <jeff.duckett-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Just wondering if this is possible and how to configure routes.rb > > Let''s say in routes.rb I have: > > map.resources :products > > this would allow me to use: > > new_product_path and the url would be /product/new > edit_product_path and the url would be /product/1/edit > > I would like to add another method to the controller that would be > exactly like the "new" method. > > my_method_product_path and the url would be /product/my_method > > I tried: > > map.resources :products, :member => { :my_method => :get} > > but, the method wants a parameter like my_method_product_path(0) > > How would I configure the routes.rb to accomplish this task?? > > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
to make a route without parameters don''t use :member. as ryan says it depends on what you want to do. it could be : with a "new" parameter map.resources :products, :new => { :my_method => :get} you will call it new_my_method_product_path or with a "collection" parameter map.resources :products, :collection => { :my_method => :get} you will call it my_method_products_path On Jan 24, 1:26 am, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> can you give us more information on what this action is supposed to do? > > On Jan 24, 2008 10:04 AM, TheDuckman <jeff.duck...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Just wondering if this is possible and how to configure routes.rb > > > Let''s say in routes.rb I have: > > > map.resources :products > > > this would allow me to use: > > > new_product_path and the url would be /product/new > > edit_product_path and the url would be /product/1/edit > > > I would like to add another method to the controller that would be > > exactly like the "new" method. > > > my_method_product_path and the url would be /product/my_method > > > I tried: > > > map.resources :products, :member => { :my_method => :get} > > > but, the method wants a parameter like my_method_product_path(0) > > > How would I configure the routes.rb to accomplish this task?? > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have a related question. I started off with: map.resources :listings map.resources :categories Then I wanted to display listings that belong to a certain category at "/listings/category", so I added the following to my routes: map.resources :listings, :requirements => { :id => /[0-9]/} map.abc ''listings/:id'', :controller => ''listings'', :action => ''show_constrained'' map.abc ''listings/:id.:format'', :controller => ''listings'', :action => ''show_constrained'' This is successful in routing requests to the right actions, but it gives me only one helper method for the named route ''abc'', which then becomes a problem for me. Am I going about this the wrong way? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---