I''ve tried to upgrade my Rails 1.5 app to 2.0.2 I''ve run into this error: Showing login/login.rhtml where line #4 raised: undefined method `user_path'' for #<ActionView::Base:0x35cd55c> Extracted source (around line #4): 1: <fieldset> 2: <legend>Please Log In</legend> 3: 4: <% form_for User do %> 5: 6: <p> 7: <label for="user_name">Name:</label> What''s wrong with the code at line #4? Am I missing something big here on the switch to 2.0? Thanks for your help, -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Floyd
2008-Feb-07 16:40 UTC
Re: Rails 2.0.2 upgrade -> undefined method `user_path''
Ok, figured it out. Just had to change form_for User to form_for :user Hope this will help someone -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rick DeNatale
2008-Feb-07 22:12 UTC
Re: Rails 2.0.2 upgrade -> undefined method `user_path''
On 2/7/08, Jason Floyd <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Ok, figured it out. > > Just had to change > > form_for User > > to > > form_for :user >Although if you''re really serious about conversion to 2.0 you might want to attack this from the other direction. user_path is missing because you don''t have a named route for user. In a conventional rails 2.0 restful application the controller for User would be named UsersController, and in the config/routes.rb you''d have ActionController::Routing::Routes.draw do |map| map.resources :users which would generate a bunch of named routes and path/url helpers including the missing user_path AND in form for you can use form_for @user and it would automatically figure out what to generate including making the form post if @user is a new record, and update if not. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---