Class: CamaleonCms::Admin::Appearances::Widgets::MainController

Inherits:
CamaleonCms::AdminController
  • Object
show all
Defined in:
app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 20

def create
  params[:widget_main][:status] = "simple"
  @widget = current_site.widgets.new(params.require(:widget_main).permit!)
  if @widget.save!
    flash[:notice] = t('camaleon_cms.admin.widgets.message.created')
  else
    flash[:error] = t('camaleon_cms.admin.widgets.message.error_created')
  end
  redirect_to action: :index
end

#destroyObject



40
41
42
43
44
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 40

def destroy
  @widget = @widget.destroy!
  flash[:notice] = t('camaleon_cms.admin.widgets.message.deleted')
  redirect_to action: :index
end

#editObject



16
17
18
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 16

def edit
  new
end

#indexObject



7
8
9
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 7

def index
  @widgets = current_site.widgets
end

#newObject



11
12
13
14
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 11

def new
  @widget ||= current_site.widgets.new
  render "form", layout: false
end

#updateObject



31
32
33
34
35
36
37
38
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 31

def update
  if @widget.update!(params.require(:widget_main).permit!)
    flash[:notice] = t('camaleon_cms.admin.widgets.message.updated')
  else
    flash[:error] = t('camaleon_cms.admin.widgets.message.error_updated')
  end
  redirect_to action: :index
end