Class: GacoCms::Admin::FieldGroupsController
- Inherits:
-
BaseController
- Object
- GacoCms::AdminController
- BaseController
- GacoCms::Admin::FieldGroupsController
- Defined in:
- app/controllers/gaco_cms/admin/field_groups_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #new_field ⇒ Object
- #tpl ⇒ Object
- #update ⇒ Object
Methods inherited from BaseController
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 18 def create group = FieldGroup.new(group_params) if group.save redirect_to url_for(action: :index), notice: 'Group saved' else render inline: group.errors..join(', ') end end |
#destroy ⇒ Object
39 40 41 42 |
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 39 def destroy @group.destroy! redirect_to url_for(action: :index), notice: 'Group destroyed' end |
#edit ⇒ Object
27 28 29 |
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 27 def edit render :form end |
#index ⇒ Object
9 10 11 |
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 9 def index @groups = FieldGroup.ordered.all end |
#new ⇒ Object
13 14 15 16 |
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 13 def new @group = FieldGroup.new render :form end |
#new_field ⇒ Object
49 50 51 52 |
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 49 def new_field field = Field.new(kind: params[:kind]) render partial: 'field', locals: { field: field } end |
#tpl ⇒ Object
44 45 46 47 |
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 44 def tpl locals = { group: @group, field_values: FieldValue.none, group_no: Time.current.to_i } render partial: '/gaco_cms/admin/fields/render/group', locals: locals end |
#update ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 31 def update if @group.update(group_params) redirect_to url_for(action: :index), notice: 'Group updated' else render inline: @group.errors..join(', ') end end |