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