My routes seem setup correctly, but are generating incompatible urls
My "link_to" and "url_for" etc. methods are generating paths in the pattern of ":controller/:id/:action", instead of ":controller/:action:/:id" - in other words my "action" and "id" fields in the url are getting swapped.
I've narrowed it down to these generated links through doing some route debugging, however, I don't quite understand how the routes.rb file can say one thing, but the generated routes 开发者_如何学编程can be in a different order. Is there something more to this than the routes file alone?
*In case it matters, I'm also using authlogic to do my user authentication.
Here's my routes.rb file, with the comments removed.
map.resources :tags
map.resources :ratings
map.resources :users
map.resources :bids
map.resources :listings
map.resource :user_session
map.root :controller => "user_sessions", :action => "new"
map.resource :account, :controller => "users"
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
Thanks!
Uh...I might have solved my problem, though I don't know how.
The URLs still seem wrong to me, clicking on the "Show", "Edit" or "Destroy" links used to take me to an error page where I'd get a nil reference error due to the funky routes.
I just did a "rake db:migrate:redo STEP=3" after making a small change to one of my previous migrations, restarting the web server, and now the app navigates without error.
What I still don't understand though, is that the generated links are still ":controller/:id/:action", but it's suddenly it's decoding properly.
Very confused.
精彩评论