Class: Api::AttributesController
- Inherits:
-
ApiController
- Object
- ActionController::Base
- ApiController
- Api::AttributesController
- Defined in:
- app/controllers/api/attributes_controller.rb
Instance Method Summary collapse
Methods inherited from ApiController
Instance Method Details
#create ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/api/attributes_controller.rb', line 27 def create render nothing: true, status: 400 unless params[:attribute] attribute = BillyCms::AdditionalAttribute.new attributes_params if attribute.save render json: { success: true, attribute: attribute } else render json: { success: false, error: attribute.errors..join('. '), }, status: 500 end end |
#destroy ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/api/attributes_controller.rb', line 43 def destroy render :nothing, status: 400 unless params[:id] if BillyCms::AdditionalAttribute.delete(params[:id]) render json: { success: true } else render json: { success: false, error: attribute., }, status: 500 end end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/api/attributes_controller.rb', line 3 def index render json: BillyCms::AdditionalAttribute.all end |
#show ⇒ Object
7 8 9 |
# File 'app/controllers/api/attributes_controller.rb', line 7 def show render json: BillyCms::AdditionalAttribute.find(params[:id]) end |
#update ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/api/attributes_controller.rb', line 11 def update render nothing: true, status: 400 unless params[:attribute] attribute = BillyCms::AdditionalAttribute.find params[:id] if attribute.update_attributes attributes_params render json: { success: true, attribute: attribute } else render json: { success: false, error: attribute., }, status: 500 end end |