Guest User

Untitled

a guest
Apr 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. I want to let the user edit his account information. But I want him to enter his old password aswell for verification.
  2.  
  3. My form looks like this
  4.  
  5. <% form_for @user, :url => account_path do |f| %>
  6. <%= f.error_messages %>
  7. <%= f.label :email %><br />
  8. <%= f.text_field :email %><br />
  9. <br />
  10. <%= f.label :password, form.object.new_record? ? nil : "Change password" %><br />
  11. <%= f.password_field :password %><br />
  12. <br />
  13. <%= f.label :password_confirmation %><br />
  14. <%= f.password_field :password_confirmation %><br />
  15.  
  16. <%= f.submit "Update" %>
  17. <% end %>
  18.  
  19.  
  20. I want to be able to have the following i the form
  21.  
  22. <%= f.label :old_password %><br />
  23. <%= f.hidden_field :old_password %><br />
  24.  
  25.  
  26. so when he submits i can do
  27.  
  28. if !@user.valid_password?(params[:old_password])
  29. flash[:notice] = "Old Password didn't match!!"
  30. render :action => :edit
  31. end
Add Comment
Please, Sign In to add comment