Added config option database_prefix
Jeremy Steinberg
committed Aug 29, 2011
commit f55986ceddbc50d78c3c610798497a160c23963d
Showing 12
changed files with
28 additions
and 0 deletions
app/models/cms/block.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| class Cms::Block < ActiveRecord::Base | |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| set_table_name :cms_blocks | |
app/models/cms/categorization.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| class Cms::Categorization < ActiveRecord::Base | |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| set_table_name :cms_categorizations | |
app/models/cms/category.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| class Cms::Category < ActiveRecord::Base | |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| set_table_name :cms_categories | |
app/models/cms/file.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| class Cms::File < ActiveRecord::Base | |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| set_table_name :cms_files | |
app/models/cms/layout.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| class Cms::Layout < ActiveRecord::Base | |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| set_table_name :cms_layouts | |
app/models/cms/page.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| class Cms::Page < ActiveRecord::Base | |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| set_table_name :cms_pages | |
app/models/cms/revision.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| class Cms::Revision < ActiveRecord::Base | |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| set_table_name :cms_revisions | |
app/models/cms/site.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| class Cms::Site < ActiveRecord::Base | |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| set_table_name :cms_sites | |
app/models/cms/snippet.rb
+1
-0
| @@ | @@ -1,4 +1,5 @@ |
| class Cms::Snippet < ActiveRecord::Base | |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| set_table_name :cms_snippets | |
config/database.yml
+6
-0
| @@ | @@ -5,6 +5,12 @@ development: |
| database: db/development.sqlite3 | |
| pool: 5 | |
| timeout: 10000 | |
| + | |
| + | cms_development: |
| + | adapter: sqlite3 |
| + | database: db/cms_development.sqlite3 |
| + | pool: 5 |
| + | timeout: 10000 |
| # Warning: The database defined as "test" will be erased and | |
| # re-generated from your development database when you run "rake". | |
config/initializers/comfortable_mexican_sofa.rb
+6
-0
| @@ | @@ -49,6 +49,12 @@ ComfortableMexicanSofa.configure do |config| |
| # force it to English by setting this to `:en` | |
| # config.admin_locale = nil | |
| + | # Database prefix. If you want to keep your comfortable mexican sofa tables |
| + | # in a location other than the default databases add a database_prefix. |
| + | # Using a prefix of `cms_` will look for a cms_#{Rails.env} definition |
| + | # in your database.yml file |
| + | config.database_prefix = 'cms_' |
| + | |
| end | |
| # Default credentials for ComfortableMexicanSofa::HttpAuth | |
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb
+7
-0
| @@ | @@ -40,6 +40,12 @@ class ComfortableMexicanSofa::Configuration |
| # force it to English by setting this to `:en` | |
| attr_accessor :admin_locale | |
| + | # Database prefix. If you want to keep your comfortable mexican sofa tables |
| + | # in a location other than the default databases add a database_prefix. |
| + | # Using a prefix of `cms_` will look for a cms_#{Rails.env} definition |
| + | # in your database.yml file |
| + | attr_accessor :database_prefix |
| + | |
| # Configuration defaults | |
| def initialize | |
| @cms_title = 'ComfortableMexicanSofa MicroCMS' | |
| @@ | @@ -55,6 +61,7 @@ class ComfortableMexicanSofa::Configuration |
| @revisions_limit = 25 | |
| @locales = { :en => 'English', :es => 'Español' } | |
| @admin_locale = nil | |
| + | @database_prefix = nil |
| end | |
| end | |