Class: Api::V1::UsersController
- Inherits:
-
BaseApiController
- Object
- ApplicationController
- BaseApiController
- Api::V1::UsersController
- Defined in:
- lib/voyage/templates/api_users_controller.rb
Instance Method Summary collapse
Methods inherited from BaseApiController
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/voyage/templates/api_users_controller.rb', line 16 def create @user = User.new(user_params) if @user.save respond_with @user do |format| format.json { render json: @user, status: :created } end else respond_with_errors(@user) end end |
#destroy ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/voyage/templates/api_users_controller.rb', line 38 def destroy user = User.find(params[:id]) if user.destroy render json: {}, status: 204 else render json: {}, status: 500 end end |
#index ⇒ Object
7 8 9 |
# File 'lib/voyage/templates/api_users_controller.rb', line 7 def index respond_with(User.all) end |
#show ⇒ Object
11 12 13 14 |
# File 'lib/voyage/templates/api_users_controller.rb', line 11 def show @user = User.find(params[:id]) respond_with(@user) end |
#update ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/voyage/templates/api_users_controller.rb', line 28 def update @user = User.find(params[:id]) if @user.update_attributes(user_params) respond_with(@user) else respond_with_errors(@user) end end |