app/controllers/users_controller.rb
class UsersController < ApplicationController
before_action :set_user, only: [:edit, :update]
def edit
end
def update
respond_to do |format|
if @user.update(user_params)
gflash success: 'Post was successfully updated.'
format.html { redirect_to edit_user_path }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end
private
def set_user
@user = current_user
end
def user_params
params.require(:user).permit(:nickname).to_hash
end
end