loading rails engine only if it's not a standalone installation

Oleg committed Oct 14, 2010
commit 648362a9123ed0f01c13bab252f51a7418fb03c6
Showing 3 changed files with 45 additions and 2 deletions
app/controllers/cms_admin/sites_controller.rb +38 -0
@@ @@ -0,0 +1,38 @@
+ class CmsAdmin::SitesController < CmsAdmin::BaseController
+
+ before_filter :load_site, :only => [:edit, :update, :destroy]
+
+ def index
+
+ end
+
+ def new
+
+ end
+
+ def edit
+
+ end
+
+ def create
+
+ end
+
+ def update
+
+ end
+
+ def destroy
+
+ end
+
+ protected
+
+ def load_site
+ @cms_site = CmsSite.find(params[:id])
+ rescue ActiveRecord::RecordInvalid
+ flash[:error] = 'Site not found'
+ redirect_to :action => :index
+ end
+
+ end
\ No newline at end of file
config/routes.rb +1 -0
@@ @@ -1,6 +1,7 @@
Rails.application.routes.draw do
namespace :cms_admin, :path => 'cms-admin', :except => :show do
+ resources :sites
resources :layouts
resources :pages do
member do
comfortable_mexican_sofa.rb b/lib/comfortable_mexican_sofa.rb +6 -2
@@ @@ -1,5 +1,9 @@
- [ 'comfortable_mexican_sofa/cms_engine',
- 'comfortable_mexican_sofa/cms_configuration',
+ # Loading engine only if this is not a standalone installation
+ unless defined? ComfortableMexicanSofa::Application
+ require File.expand_path('comfortable_mexican_sofa/cms_engine', File.dirname(__FILE__))
+ end
+
+ [ 'comfortable_mexican_sofa/cms_configuration',
'comfortable_mexican_sofa/cms_http_authentication',
'comfortable_mexican_sofa/cms_rails_extensions',
'comfortable_mexican_sofa/cms_form_builder',