Class: CamaleonCms::Admin::Appearances::Widgets::MainController
Instance Method Summary
collapse
#ajax, #cama_get_i18n_frontend, #dashboard, #search
Instance Method Details
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 24
def create
@widget = current_site
.widgets.new(params.require(:widget_main).permit(:name, :slug, :description, :excerpt, :renderer))
@widget.status = 'simple'
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
|
#destroy ⇒ Object
45
46
47
48
49
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 45
def destroy
@widget = @widget.destroy!
flash[:notice] = t('camaleon_cms.admin.widgets.message.deleted')
redirect_to action: :index
end
|
#edit ⇒ Object
20
21
22
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 20
def edit
new
end
|
#index ⇒ Object
11
12
13
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 11
def index
@widgets = current_site.widgets.order :name
end
|
#new ⇒ Object
15
16
17
18
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 15
def new
@widget ||= current_site.widgets.new
render 'form', layout: false
end
|
#update ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb', line 36
def update
if @widget.update!(params.require(:widget_main).permit(:name, :slug, :description, :excerpt, :renderer))
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
|