user_credentials_controller.rb 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. class UserCredentialsController < ApplicationController
  2. def index
  3. @user_credentials = current_user.user_credentials.page(params[:page])
  4. respond_to do |format|
  5. format.html
  6. format.json { render json: @user_credentials }
  7. end
  8. end
  9. def new
  10. @user_credential = current_user.user_credentials.build
  11. respond_to do |format|
  12. format.html
  13. format.json { render json: @user_credential }
  14. end
  15. end
  16. def edit
  17. @user_credential = current_user.user_credentials.find(params[:id])
  18. end
  19. def create
  20. @user_credential = current_user.user_credentials.build(params[:user_credential])
  21. respond_to do |format|
  22. if @user_credential.save
  23. format.html { redirect_to user_credentials_path, notice: 'Your credential was successfully created.' }
  24. format.json { render json: @user_credential, status: :created, location: @user_credential }
  25. else
  26. format.html { render action: "new" }
  27. format.json { render json: @user_credential.errors, status: :unprocessable_entity }
  28. end
  29. end
  30. end
  31. def update
  32. @user_credential = current_user.user_credentials.find(params[:id])
  33. respond_to do |format|
  34. if @user_credential.update_attributes(params[:user_credential])
  35. format.html { redirect_to user_credentials_path, notice: 'Your credential was successfully updated.' }
  36. format.json { head :no_content }
  37. else
  38. format.html { render action: "edit" }
  39. format.json { render json: @user_credential.errors, status: :unprocessable_entity }
  40. end
  41. end
  42. end
  43. def destroy
  44. @user_credential = current_user.user_credentials.find(params[:id])
  45. @user_credential.destroy
  46. respond_to do |format|
  47. format.html { redirect_to user_credentials_path }
  48. format.json { head :no_content }
  49. end
  50. end
  51. end