Sha256: 9f75a9eaba028baf80b89c7da855cad14c46674f4d40cef6d87c0a3c0cf3b476

Contents?: true

Size: 1.09 KB

Versions: 40

Compression:

Stored size: 1.09 KB

Contents

require_dependency "faalis/application_controller"

module Faalis
  class API::V1::ProfilesController < ::APIController

    def show
      @user = current_user
      respond_with(@user)
    end

    def update
      @user = current_user
      user_fields = {
        :first_name => params[:first_name],
        :last_name => params[:last_name],
        :email => params[:email],
      }

      if params.include? :password and params[:password]
        user_fields[:password] =  params[:password]
        user_fields[:password_confirmation] =  params[:password_confirmation]

        if @user.update(user_fields)
          respond_with(@user)
        else
          respond_to do |format|
            format.json { render :json => {:fields => @user.errors}, :status => :unprocessable_entity }
          end
        end
      else

        if @user.update_without_password(user_fields)
          respond_with(@user)
        else
          respond_to do |format|
            format.json { render :json => {:fields => @user.errors}, :status => :unprocessable_entity }
          end
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
faalis-0.26.1 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.26.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.25.1 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.25.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.24.4 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.24.3 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.24.2 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.24.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.23.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.22.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.21.1 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.21.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.20.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.19.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.18.1 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.18.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.17.0 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.16.3 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.16.1 app/controllers/faalis/api/v1/profiles_controller.rb
faalis-0.16.0 app/controllers/faalis/api/v1/profiles_controller.rb