Guest User

Untitled

a guest
Jul 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. # PUT /users/1
  2. def update
  3. @user = User.find(params[:id])
  4.  
  5. if @user.update_attributes(params[:user])
  6. if params[:profile][:available] == 1 #available is a checkbox that stores a simple flag in the database.
  7. @user.create_profile(params[:profile])
  8. end
  9. else
  10. #some warnings and errors
  11. end
  12. end
  13.  
  14. Profile.new(:user_id => @user.id)
  15.  
  16. Profile.create(:user_id => @user.id)
  17.  
  18. profile = @user.build_profile
  19. profile.save
Add Comment
Please, Sign In to add comment