Routting question

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.

This should work:

map.resources :compounds, :collection => { :calculator => :get }

You need to add a member option to your route.

Please read

heimdull wrote:

This should work:

map.resources :compounds, :collection => { :calculator => :get }

thanks! worked great.