Class: GacoCms::Admin::FieldGroupsController

Inherits:
BaseController show all
Defined in:
app/controllers/gaco_cms/admin/field_groups_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#upload_file

Instance Method Details

#createObject



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.full_messages.join(', ')
  end
end

#destroyObject



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

#editObject



27
28
29
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 27

def edit
  render :form
end

#indexObject



9
10
11
# File 'app/controllers/gaco_cms/admin/field_groups_controller.rb', line 9

def index
  @groups = FieldGroup.ordered.all
end

#newObject



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_fieldObject



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

#tplObject



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

#updateObject



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.full_messages.join(', ')
  end
end