Guest User

Untitled

a guest
May 20th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. class UserprofilesController < ApplicationController
  2. def show
  3. @userprofile = current_user.userprofile.find(params[:id])
  4. end
  5.  
  6. def new
  7. @userprofile = current_user.build_userprofile
  8. end
  9.  
  10. def create
  11. @userprofile = current_user.build_userprofile(params[:userprofile])
  12. if @userprofile.save
  13. notice = "Successfully set your profile."
  14. redirect_to welcome_url
  15. else
  16. render :new
  17. end
  18. end
  19.  
  20. def edit
  21. @userprofile = current_user.userprofile.find(params[:id])
  22. end
  23.  
  24. def update
  25. @userprofile = current_user.userprofile.find(params[:id])
  26. if @userprofile.update_attributes(params[:userprofile])
  27. notice = "Successfully updated your profile."
  28. redirect_to @userprofile
  29. else
  30. render :edit
  31. end
  32. end
  33.  
  34. def destroy
  35. @userprofile = current_user.userprofile.find(params[:id])
  36. @userprofile.destroy
  37. notice = "Successfully destroyed user profile."
  38. redirect_to root_url
  39. end
  40. end
Add Comment
Please, Sign In to add comment