Class: UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/auth/templates/controllers/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

app/controllers/users_controller.rb



6
7
8
9
10
11
12
13
# File 'lib/generators/auth/templates/controllers/users_controller.rb', line 6

def create 
    user = User.create!(user_params)
    @token = encode_token(user_id: user.id)
    render json: {
        user: UserSerializer.new(user), 
        token: @token
    }, status: :created
end

#meObject



15
16
17
# File 'lib/generators/auth/templates/controllers/users_controller.rb', line 15

def me 
  render json: current_user, status: :ok
end