From eed8f1dd837f2d09e8d8c549d18c558367977ae8 Mon Sep 17 00:00:00 2001 From: Amaia Castro Date: Tue, 27 Dec 2016 12:32:07 +0100 Subject: [PATCH] Set admin layout for admin sandbox templates --- app/controllers/sandbox_controller.rb | 18 ++++++++++++++++++ ...ox.html.erb => admin_test_sandbox.html.erb} | 0 2 files changed, 18 insertions(+) rename app/views/sandbox/{test_sandbox.html.erb => admin_test_sandbox.html.erb} (100%) diff --git a/app/controllers/sandbox_controller.rb b/app/controllers/sandbox_controller.rb index ea5a3e96b..12b5dd91e 100644 --- a/app/controllers/sandbox_controller.rb +++ b/app/controllers/sandbox_controller.rb @@ -1,6 +1,10 @@ class SandboxController < ApplicationController skip_authorization_check + layout :set_layout + + helper_method(:namespace) + def index @templates = Dir.glob(Rails.root.join('app/views/sandbox/*.html.erb').to_s).map do |filename| filename = File.basename(filename, File.extname(filename)) @@ -24,4 +28,18 @@ class SandboxController < ApplicationController render :action => "index" end end + + private + + def set_layout + if params[:template] && params[:template].split("_").first == "admin" + "admin" + else + "application" + end + end + + def namespace + "admin" + end end diff --git a/app/views/sandbox/test_sandbox.html.erb b/app/views/sandbox/admin_test_sandbox.html.erb similarity index 100% rename from app/views/sandbox/test_sandbox.html.erb rename to app/views/sandbox/admin_test_sandbox.html.erb