Sha256: db5e254aaadf4af90c3449c507de43c29a7951e5a22c7ecb3c132860ce79a6dc
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
module ConstructorPages class PagesController < ConstructorCore::ApplicationController include TheSortableTreeController::Rebuild include TheSortableTreeController::ExpandNode skip_before_filter :authenticate_user!, only: [:show] before_action :set_page, only: [:edit, :update, :destroy] def index @pages = Page.roots end def new @page, @templates = Page.new, Template.all if @templates.blank? redirect_to pages_path, notice: t(:create_template_first) end end def show @page = Page.find_by_path request.path redirect_to(@page.redirect) && return if @page.redirect? _code_name = @page.template.code_name instance_variable_set('@'+_code_name, @page) render "templates/#{_code_name}", layout: 'application' end def edit end def create @page = Page.new page_params if @page.save redirect_to pages_path, notice: t(:page_success_added, name: @page.name) else render :new end end def update if @page.update page_params @page.update_fields_values params[:fields] redirect_to pages_path, notice: t(:page_success_updated, name: @page.name) else render :edit end end def destroy @page.destroy redirect_to pages_path, notice: t(:page_success_removed, name: @page.name) end def sortable_model; Page end private def set_page @page = Page.find params[:id] end def page_params params.require(:page).permit( :active, :name, :url, :title, :keywords, :description, :auto_url, :template_id, :in_nav, :in_map, :in_menu, :in_url, :redirect ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
constructor-pages-1.0.0beta2 | app/controllers/constructor_pages/pages_controller.rb |