Class: Testapi::ModelsController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- Testapi::ModelsController
- Defined in:
- app/controllers/testapi/models_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
9 10 11 12 |
# File 'app/controllers/testapi/models_controller.rb', line 9 def create @object = model.create!(attributes) render_object end |
#destroy ⇒ Object
25 26 27 28 29 |
# File 'app/controllers/testapi/models_controller.rb', line 25 def destroy @object = model.find(params[:id]) @object.destroy! render_object end |
#index ⇒ Object
4 5 6 7 |
# File 'app/controllers/testapi/models_controller.rb', line 4 def index @objects = model.all.reorder(:id) render_json @objects.map(&:attributes) end |
#show ⇒ Object
14 15 16 17 |
# File 'app/controllers/testapi/models_controller.rb', line 14 def show @object = model.find(params[:id]) render_object end |
#update ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/testapi/models_controller.rb', line 19 def update @object = model.find(params[:id]) @object.update!(attributes) render_object end |