Class: Cms::Admin::FormFieldsController
- Inherits:
-
BaseController
- Object
- BaseController
- Cms::Admin::FormFieldsController
- Defined in:
- app/controllers/cms/admin/form_fields_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #sort ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/cms/admin/form_fields_controller.rb', line 19 def create @field = @page.form_fields.build(field_params) if @field.save redirect_to admin_page_form_fields_path(@page), notice: t("cms.notices.field_added") else render :new, status: :unprocessable_content end end |
#destroy ⇒ Object
39 40 41 42 |
# File 'app/controllers/cms/admin/form_fields_controller.rb', line 39 def destroy @field.destroy redirect_to admin_page_form_fields_path(@page), notice: t("cms.notices.field_removed") end |
#edit ⇒ Object
17 |
# File 'app/controllers/cms/admin/form_fields_controller.rb', line 17 def edit; end |
#index ⇒ Object
9 10 11 |
# File 'app/controllers/cms/admin/form_fields_controller.rb', line 9 def index @fields = @page.form_fields.ordered end |
#new ⇒ Object
13 14 15 |
# File 'app/controllers/cms/admin/form_fields_controller.rb', line 13 def new @field = @page.form_fields.build(position: @page.form_fields.count) end |
#sort ⇒ Object
44 45 46 47 48 49 |
# File 'app/controllers/cms/admin/form_fields_controller.rb', line 44 def sort Array(params[:field_ids]).each_with_index do |id, position| @page.form_fields.find(id).update!(position: position) end head :ok end |
#update ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/cms/admin/form_fields_controller.rb', line 29 def update @field.assign_attributes(field_params) if @field.save redirect_to admin_page_form_fields_path(@page), notice: t("cms.notices.field_updated") else render :edit, status: :unprocessable_content end end |