diff --git a/app/controllers/formbuilder/forms_controller.rb b/app/controllers/formbuilder/forms_controller.rb index e0aa1de..f7e9fa5 100644 --- a/app/controllers/formbuilder/forms_controller.rb +++ b/app/controllers/formbuilder/forms_controller.rb @@ -32,7 +32,7 @@ def update rf.cid = cids[rf.id] end - render json: @form.response_fields.to_json(methods: [:field_type, :cid]) + render json: @form.response_fields_json end private diff --git a/app/models/formbuilder/form.rb b/app/models/formbuilder/form.rb index 85f6d89..fb3e58a 100644 --- a/app/models/formbuilder/form.rb +++ b/app/models/formbuilder/form.rb @@ -8,5 +8,9 @@ def input_fields response_fields.reject { |rf| !rf.input_field } end + def response_fields_json + self.response_fields.to_json(methods: [:field_type, :cid]) + end + end end