Class: Ishapi::UserProfilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ishapi/user_profiles_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#exception, #home, #long_term_token, #vote

Instance Method Details

#check_profileObject

@TODO: hmmm I may not need this check at all



5
# File 'app/controllers/ishapi/user_profiles_controller.rb', line 5

before_action :check_profile, only: %i| show |

#showObject



9
10
11
12
# File 'app/controllers/ishapi/user_profiles_controller.rb', line 9

def show
  @profile = Ish::UserProfile.find_by :username => params[:username]
  authorize! :show, @profile
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/ishapi/user_profiles_controller.rb', line 14

def update
  @profile = Ish::UserProfile.find @current_user.profile
  authorize! :update, @profile

  flag = @profile.update params[:profile].permit!
  if flag
    render json: { message: 'ok' }, status: :ok
  else
    render json: { message: "No luck: #{@profile.errors.full_messages.join(", ")}." }, code: 400
  end
end