Class: BaseApiController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- BaseApiController
- Defined in:
- lib/baseapi/app/controllers/base_api_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /models/id.json.
-
#destroy ⇒ Object
DELETE /models/id.json.
-
#index ⇒ Object
GET /models.json.
-
#show ⇒ Object
GET /models/id.json.
-
#update ⇒ Object
PATCH/PUT /models/id.json.
Instance Method Details
#create ⇒ Object
POST /models/id.json
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/baseapi/app/controllers/base_api_controller.rb', line 23 def create render 'model.json.jbuilder' if transaction(-> { params.each do |key, value| if key.present? and value.present? and @Model.column_names.include?(key) @model.send("#{key}=", value) end end @model.save }) end |
#destroy ⇒ Object
DELETE /models/id.json
51 52 53 54 55 |
# File 'lib/baseapi/app/controllers/base_api_controller.rb', line 51 def destroy render 'model.json.jbuilder' if transaction(-> { @model._destroy }) end |
#index ⇒ Object
GET /models.json
10 11 12 |
# File 'lib/baseapi/app/controllers/base_api_controller.rb', line 10 def index render 'models.json.jbuilder' end |
#show ⇒ Object
GET /models/id.json
16 17 18 |
# File 'lib/baseapi/app/controllers/base_api_controller.rb', line 16 def show render 'model.json.jbuilder' end |
#update ⇒ Object
PATCH/PUT /models/id.json
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/baseapi/app/controllers/base_api_controller.rb', line 37 def update render 'model.json.jbuilder' if transaction(-> { params.each do |key, value| if key.present? and value.present? and @Model.column_names.include?(key) @model.send("#{key}=", value) end end @model.save }) end |