routes.rb

View: New views
5 Messages — Rating Filter:   Alert me  

routes.rb

by Justinmc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I feel like I'm doing something stupid, because I haven't been able to
fix this.

I have this in my routes.rb file:

 map.resources :networks, :has_many => :nodes
  map.resources :auth
  map.connect 'users/login', :controller => 'users', :action =>
'login'
  map.resources :users
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'

I'm trying to generate an url that goest to localhost:3000/users/
login .... but no matter what I do, that url always tries to work
through the "show" action as opposed to the "login" action I have in
the users controller.

What am I doing wrong?

--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: routes.rb

by deegee-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


hi justin,
my first guess is that are not reloading the routing table after
making the change. Remember to restart the server for new routes to
take effect. When I check in my code, your route just works fine.

dirk.
--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: routes.rb

by unni.tallman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Add the line

map.connect 'users/login', :controller => 'users', :action => 'login'

after

map.resources :users

in your routes.rb

On Jul 25, 5:21 pm, deegee <dirkgro...@...> wrote:
> hi justin,
> my first guess is that are not reloading the routing table after
> making the change. Remember to restart the server for new routes to
> take effect. When I check in my code, your route just works fine.
>
> dirk.
--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: routes.rb

by deegee-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Why should that work? Routes are consulted in the order they are
defined in routes.rb. So if you have
 map.resources :users
before
 map.connect '/users/login'
it will catch the '/users/:id' declaration of the RESTful resource
routes and always get justin to the show action before it even reaches
the '/users/login' declaration.

dirk.
--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: routes.rb

by unni.tallman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


thats right. the order is from top to bottom. It was my mistake.

On Jul 25, 5:33 pm, deegee <dirkgro...@...> wrote:

> Why should that work? Routes are consulted in the order they are
> defined in routes.rb. So if you have
>  map.resources :users
> before
>  map.connect '/users/login'
> it will catch the '/users/:id' declaration of the RESTful resource
> routes and always get justin to the show action before it even reaches
> the '/users/login' declaration.
>
> dirk.
--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---