I have a controller with the default functions index, edit, update...etc but i want to add another route calculator. my current setup: compounds_controller.rb def index ... def calculator ... end i also added views/compounds/calculator.html.erb i have the default entry in the routes: map.resources :compounds how can i get it to map to http://localhost/compounds/calculator ? i tried doing: map.calculator ''/compounds/calculator'', :controller => ''compounds'', :action => ''calculator'' but it''s not working. i tried reading through some of the routes documentation but was getting a little confused. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Thu, Jul 31, 2008 at 6:58 PM, Scott Kulik < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > map.resources :compounds > > how can i get it to map to http://localhost/compounds/calculator ?map.resources :compunds, :member => { :calculator => :get } change :get to be whatever verb you need. -- tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This should work: map.resources :compounds, :collection => { :calculator => :get } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You need to add a member option to your route. Please read http://frozenplague.net/2008/01/06/restful-routing-an-overview/ On 01/08/2008, at 8:28 AM, Scott Kulik wrote:> > I have a controller with the default functions index, edit, > update...etc > but i want to add another route calculator. > > my current setup: > > compounds_controller.rb > def index > ... > def calculator > ... > end > > i also added views/compounds/calculator.html.erb > > i have the default entry in the routes: > > map.resources :compounds > > how can i get it to map to http://localhost/compounds/calculator ? > > i tried doing: > > map.calculator ''/compounds/calculator'', :controller => ''compounds'', > :action => ''calculator'' > > but it''s not working. > > i tried reading through some of the routes documentation but was > getting > a little confused. > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
heimdull wrote:> This should work: > > map.resources :compounds, :collection => { :calculator => :get }thanks! worked great. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Verbs are: :get, :post, :put, :delete and :any --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---