Class: Stay::Api::V1::ProfilesController

Inherits:
BaseApiController
  • Object
show all
Defined in:
app/controllers/stay/api/v1/profiles_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



4
5
6
# File 'app/controllers/stay/api/v1/profiles_controller.rb', line 4

def show
  render json: { profile: @profile }
end

#updateObject



8
9
10
11
12
13
14
15
# File 'app/controllers/stay/api/v1/profiles_controller.rb', line 8

def update 
  if @profile.update(profile_params)
    data = ActiveModelSerializers::SerializableResource.new(@profile, serializer: UserSerializer)
    render json: { profile: data, success: true }, status: :ok
  else
    render json: { errors: @profile.errors.full_messages, success:false }, status: :unprocessable_entity
  end
end