Class: ConstructorPages::TemplatesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ConstructorCore::ApplicationController
- ApplicationController
- ConstructorPages::TemplatesController
- Includes:
- TreeviewHelper
- Defined in:
- pages/app/controllers/constructor_pages/templates_controller.rb
Instance Method Summary collapse
Methods included from TreeviewHelper
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'pages/app/controllers/constructor_pages/templates_controller.rb', line 19 def create @template = Template.new template_params if @template.save redirect_to templates_url, notice: t(:template_success_added, name: @template.name) else render action: :new end end |
#destroy ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'pages/app/controllers/constructor_pages/templates_controller.rb', line 39 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
15 16 17 |
# File 'pages/app/controllers/constructor_pages/templates_controller.rb', line 15 def edit @template = Template.find(params[:id]) end |
#new ⇒ Object
11 12 13 |
# File 'pages/app/controllers/constructor_pages/templates_controller.rb', line 11 def new @template = Template.new end |
#update ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'pages/app/controllers/constructor_pages/templates_controller.rb', line 29 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 action: :edit end end |