Routes Misunderstanding

Hi there,

I seem to be misunderstanding routes a little bit as I can’t get the
behavior I’m expecting from the following.

My goal is to get “/forums/1” from the code <%= url_for :id =>
forum.id %> which is being called from a view associated with a
controller named “Forums” and the “index” action.

I have the following routes:

map.connect ‘forums’, :controller => “forums”, :action => “index”
map.connect ‘forums/:id’, :controller => “forums”, :action =>
“threads”

As you can see, my goal is for when someone visits “/forums” it takes
them to the index action and when someone visists “/forums/2” it takes
them to action “threads” with the id of 2. The actual redirecting and
routing works perfectly. The URLs take them to where I want them to go
but the url_for code I mentioned above generates “/forums/index/1”
which I want to avoid from happening. I’ve attempted adding :action =>
nil to the mix but that didn’t work.

Anyone got any ideas?

Thanks in advance!

  • Rick

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs