Advertisement
Guest User

Untitled

a guest
Mar 14th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. def update
  2. @user = current_user
  3. # @user.attributes = {'mail_chimp_newsletters' => []}.merge(params[:user])
  4.  
  5. if @user.update_attributes(params[:user])
  6. sign_in @user, :bypass => true
  7. redirect_to edit_account_path, :notice => 'Account has been updated!'
  8. else
  9. redirect_to edit_account_path, :flash => { :alert => "Account could not be updated. Please try again" }
  10. end
  11. end
  12.  
  13. match 'account/edit' => 'settings#edit', :as => 'edit_account', :via => :get
  14. match 'accounts' => 'settings#update', :as => 'accounts', :via => :put
  15.  
  16. <%= form_for @user, :url => accounts_url, :method => :put, :html => { :id => "personal-info-form", :class => "hide" } do |f| %>
  17.  
  18. User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 43008 LIMIT 1
  19. (0.2ms) BEGIN
  20. User Exists (36.1ms) SELECT 1 FROM `users` WHERE (`users`.`username` = BINARY 'test@test.com' AND `users`.`id` != 43008) LIMIT 1
  21. User Exists (33.4ms) SELECT 1 FROM `users` WHERE (`users`.`email` = BINARY 'test@test.com' AND `users`.`id` != 43008) LIMIT 1
  22. (0.1ms) ROLLBACK
  23.  
  24. # User model (models/user.rb)
  25. attr_accessor :email, last_name, first_name # etc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement