Class: API::V1::ContactFieldsController
- Inherits:
-
Faalis::APIController
- Object
- Faalis::APIController
- API::V1::ContactFieldsController
- Defined in:
- app/controllers/api/v1/contact_fields_controller.rb
Instance Method Summary collapse
- #build_resource ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
-
#index ⇒ Object
GET /api/v1/contact_fields.
- #resource_params ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#build_resource ⇒ Object
44 45 46 |
# File 'app/controllers/api/v1/contact_fields_controller.rb', line 44 def build_resource @contact_field = ::ContactField.new(resource_params) end |
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/api/v1/contact_fields_controller.rb', line 10 def create if @contact_field.save respond_with(@contact_field) else respond_to do |format| format.json { render :json => {:fields => @contact_field.errors}, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
37 38 39 40 41 42 |
# File 'app/controllers/api/v1/contact_fields_controller.rb', line 37 def destroy ids = params[:id].split(",") @contact_fields = ::ContactField.where(:id => ids) :destroy, @contact_fields @contact_fields.destroy_all end |
#index ⇒ Object
GET /api/v1/contact_fields
6 7 8 |
# File 'app/controllers/api/v1/contact_fields_controller.rb', line 6 def index respond_with(@contact_fields) end |
#resource_params ⇒ Object
48 49 50 |
# File 'app/controllers/api/v1/contact_fields_controller.rb', line 48 def resource_params params.require(:contact_field).permit(:id, :name, :value_type, :validation_rules) end |
#show ⇒ Object
21 22 23 |
# File 'app/controllers/api/v1/contact_fields_controller.rb', line 21 def show respond_with(@contact_field) end |
#update ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/api/v1/contact_fields_controller.rb', line 25 def update if @contact_field.update(resource_params) respond_with(@contact_field) else respond_to do |format| format.json { render :json => {:fields => @contact_field.errors}, :status => :unprocessable_entity } end end end |