Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. !!In User.rb
  2. def change_password(password)
  3. new_pass = encrypt(password)
  4. write_attribute("crypted_password", new_pass)
  5. new_pass
  6. end
  7.  
  8. !!In the controller
  9. def send_password
  10. if params[:email].any?
  11. if @user = User.find(:first, :conditions => ["email = ?", params[:email]])
  12. @new_pass = @user.change_password(generate_password)
  13. Notifier.deliver_password_reminder(@user, @new_pass)
  14. flash[:notice] = "A new password has been sent to your email..."
  15. redirect_back(2)
  16. else
  17. flash[:error] = "Your email address was not found in the system. Please register for an account."
  18. redirect_back(1)
  19. end
  20. end
  21.  
  22. !!I get this error
  23.  
  24. NoMethodError (undefined method `change_password' for #<User:0x4075fa30>)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement