On 6 July 2010 05:39, RichardOnRails <[email protected]> wrote: > Hey Niels, > > Thank you for excellent guidance. I read about routing but it's taking > me a long time to actually internalize this stuff. Your analysis > gives me hope!
Have a look at the Rails Guide on routing. As always don't just read it, play with a test app and try variants of the examples in the guide. That helps the ideas to sink in, at least it helps for me. Colin > > Best wishes, > Richard > > On Jul 5, 10:42 pm, Niels Meersschaert <[email protected]> wrote: >> map.resources creates routes for the typical CRUD operations. Since you are >> adding an additional operation, you could revise your mapping to this: >> >> map.resources :users, :collection => {:sign_in => :get} >> >> This creates awkward route names & feels ugly as you are mucking with a >> resource controller's routes. It's probably better to do: >> >> map.sign_in "/sign_in", :controller => "users", :action => "sign_in" >> >> However, as logging in is really a session issue, rather than a user >> concern, it would be even better to do something like this: >> >> map.sign_in "/sign_in", :controller => "sessions", :action => "new" >> >> Then move your sign_in method from users_controller to sessions_controller >> >> You will want a file like /path_to_controller_views/sign_in.html.erb to >> handle it (assuming you are using erb). Replace path_to_controller_views >> with either /app/views/users or /app/views/sessions as appropriate. >> >> Niels >> >> On Jul 5, 2010, at 10:02 PM, RichardOnRails wrote: >> >> > I've got the following in config\routes.rb: >> > map.resources :users >> >> > In app\views\shared\_menu.erb, I've got: >> > Please sign in <%= link_to >> > "here", :controller=>"user", :action=>"sign_in" -%> >> >> > In app\controllers\users_controller.rb >> > def sign_in >> > end >> >> > When I run the application, I crash with: >> > Routing Error >> > No route matches "/user/sign_in" with {:method=>:get} >> >> > I presume I should add "def sign_in; [snip]; end" somewhere in: >> > app\views\users >> >> > But where, so as to satisfy the Rails routing scheme? >> > Is sufficient information provided above to answer this question? >> > I'm running Rails 2.3.5 >> >> > Thanks in Advance, >> > Richard >> >> > -- >> > 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 [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group >> > athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

