Class: ConstructorPages::TemplatesController
Instance Method Summary
collapse
#arrow_buttons_for, #for_select
movable, #move_to
Instance Method Details
#create ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 24
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
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 44
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
20
21
22
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 20
def edit
@template = Template.find(params[:id])
end
|
#index ⇒ Object
11
12
13
14
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 11
def index
@templates = Template.all
@templates_cache = Digest::MD5.hexdigest(@templates.map{|t| [t.name, t.lft]}.join)
end
|
#new ⇒ Object
16
17
18
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 16
def new
@template = Template.new
end
|
#update ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/constructor_pages/templates_controller.rb', line 34
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
|