Class: Grime::ApiController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Grime::ApiController
- Defined in:
- app/controllers/grime/api_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
37 38 39 40 |
# File 'app/controllers/grime/api_controller.rb', line 37 def create @object = scope.create!(object_params_for_create) render json: @object end |
#destroy ⇒ Object
47 48 49 |
# File 'app/controllers/grime/api_controller.rb', line 47 def destroy render json: @object.destroy! end |
#index ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/controllers/grime/api_controller.rb', line 24 def index if filter_params_present? && scope.respond_to?(:where) objects = scope.where(filter_params) else objects = scope.all end render json: objects end |
#show ⇒ Object
33 34 35 |
# File 'app/controllers/grime/api_controller.rb', line 33 def show render json: @object end |
#update ⇒ Object
42 43 44 45 |
# File 'app/controllers/grime/api_controller.rb', line 42 def update @object.update!(object_params_for_update) render json: @object end |