Working through the tutorials in the RailsSpace book, and cannot figure out what I am doing wrong here. Full code for the edit function which is tossing the error as well as appropriate code from the model the actual error are pasted below. Thank you for your help. Dave ____________________________________________________________________ NoMethodError in UserController#edit private method `correct_password?'' called for #<User:0x485ee28> RAILS_ROOT: C:/instant_rails/InstantRails/rails_apps/puget/config/.. Application Trace | Framework Trace | Full Trace C:/instant_rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/ activerecord-1.15.3/lib/active_record/base.rb:1857:in `method_missing'' #{RAILS_ROOT}/app/controllers/user_controller.rb:63:in `edit'' Request Parameters: {"user"=>{"password_confirmation"=>"blip", "current_password"=>"blippi", "password"=>"bloppi"}, "commit"=>"Update", "attribute"=>"password"} Show session dump --- :user_id: 6 flash: !map:ActionController::Flash::FlashHash {} Response Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"} _________________________ user_controller.rb #Edit the user''s basic info. def edit @title = "Edit your User Information" @user = User.find(session[:user_id]) if param_posted?(:user) attribute = params[:attribute] case attribute when "email" try_to_update @user, attribute when "password" if @user.correct_password?(params) try_to_update @user, attribute else @user.password_errors(params) end end end #For security purposes, never fill in the password fields. @user.clear_password end # Try to update the user, redirecting if successful. def try_to_update(user, attribute) if user.update_attributes(params[:user]) flash[:notice] = "User #{attribute} updated." redirect_to :action => "index" end end ___________________ User.rb #Return true if the password from params is correct. def correct_password?(params) current_password = params[:user] [:current_password] password == current_password end #Generate message for password errors. def password_errors(params) #Use User models valid? method to generate error message #for a password mismatch (if any) self.password = params[:user][:password] self.password_confirmation = params[:user] [:password_confirmation] valid? #The current password is incorrect, so add an error message. errors.add(:current_password, "is incorrect") end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
wheresdave
2007-Aug-09 00:59 UTC
Re: method_missing error......need some eyes for this one
Forgot to add that line 63 in the user_controller.rb is if @user.correct_password?(params) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It''s saying that correct_password? is a private method private method `correct_password?'' called for #<User:0x485ee28> Move this above the private keyword in your User.rb file, or use the public keyword just above the method definition. HTH Daniel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
wheresdave
2007-Aug-09 01:22 UTC
Re: method_missing error......need some eyes for this one
Works like a charm. Thank you sir. On Aug 8, 6:08 pm, "Daniel N" <has....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It''s saying that correct_password? is a private method > > private method `correct_password?'' called for #<User:0x485ee28> > > Move this above the private keyword in your User.rb file, or use the public > keyword just above the method definition. > > HTH > Daniel--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---