Class: ConstructorPages::TemplatesController
Instance Method Summary
collapse
#arrow_buttons_for, #for_select
movable, #move_to
Instance Method Details
#create ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 23
def create
@template = Template.new template_params
if @template.save
redirect_to templates_url, notice: t(:template_success_added, name: @template.name)
else
render :new
end
end
|
#destroy ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 43
def destroy
@template = Template.find(params[:id])
if @template.pages.count == 0
name = @template.name
@template.destroy
redirect_to templates_url, notice: t(:template_success_removed, name: name)
else
redirect_to :back, alert: t(:template_error_delete_pages)
end
end
|
#edit ⇒ Object
19
20
21
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 19
def edit
@template = Template.find(params[:id])
end
|
#index ⇒ Object
11
12
13
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 11
def index
@templates_cache = Digest::MD5.hexdigest(@templates.map{|t| [t.id, t.name, t.lft]}.join)
end
|
#new ⇒ Object
15
16
17
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 15
def new
@template = Template.new
end
|
#update ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 33
def update
@template = Template.find params[:id]
if @template.update template_params
redirect_to templates_url, notice: t(:template_success_updated, name: @template.name)
else
render :edit
end
end
|