# controller for the dashboard
class ProfilesController < ApplicationController
  before_action :authenticate_user!, only: [:create, :update]
  before_action :set_profile, only: [:update]

  # PATCH/PUT /profiles/1
  # PATCH/PUT /profiles/1.json
  def update
    respond_to do |format|
      if @profile.update(profile_params)
        format.html { redirect_to user_profile_path(@profile.user), notice: 'Profile was successfully updated.' }
        format.json { render :show, status: :ok, location: @profile }
      else
        format.html { render :edit }
        format.json { render json: @profile.errors, status: :unprocessable_entity }
      end
    end
  end

  private

  def set_profile
    @profile = Profile.find(params[:id])
  end

  def profile_params
    params.require(:profile).permit(:avatar)
  end
end

# controller for the dashboard
class ProfilesController < ApplicationController
  before_action :authenticate_user!, only: [:create, :update]
  before_action :set_profile, only: [:update]

  # PATCH/PUT /profiles/1
  # PATCH/PUT /profiles/1.json
  def update
    respond_to do |format|
      if @profile.update(profile_params)
        format.html { redirect_to user_profile_path(@profile.user), notice: 'Profile was successfully updated.' }
        format.json { render :show, status: :ok, location: @profile }
      else
        format.html { render :edit }
        format.json { render json: @profile.errors, status: :unprocessable_entity }
      end
    end
  end

  private

  def set_profile
    @profile = Profile.find(params[:id])
  end

  def profile_params
    params
      .require(:profile)
      .permit(
        :avatar,
        :bio,
        :rate,
        :work_company,
        :work_title,
        :location,
        :twitter_username
      )
  end
end

Allow strong parameters to be editable
Allow strong parameters to be editable
