switched config option to database_config from database_prefix
Jeremy Steinberg
committed Aug 31, 2011
commit f913bce4da5a362ed6d1b09f547441625b07f189
Showing 18
changed files with
27 additions
and 26 deletions
app/models/cms/block.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| class Cms::Block < ActiveRecord::Base | |
| unless Rails.env == 'test' | |
| - | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| end | |
| set_table_name :cms_blocks | |
app/models/cms/categorization.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| class Cms::Categorization < ActiveRecord::Base | |
| unless Rails.env == 'test' | |
| - | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| end | |
| set_table_name :cms_categorizations | |
app/models/cms/category.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| class Cms::Category < ActiveRecord::Base | |
| unless Rails.env == 'test' | |
| - | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| end | |
| set_table_name :cms_categories | |
app/models/cms/file.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| class Cms::File < ActiveRecord::Base | |
| unless Rails.env == 'test' | |
| - | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| end | |
| set_table_name :cms_files | |
app/models/cms/layout.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| class Cms::Layout < ActiveRecord::Base | |
| unless Rails.env == 'test' | |
| - | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| end | |
| set_table_name :cms_layouts | |
app/models/cms/page.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| class Cms::Page < ActiveRecord::Base | |
| unless Rails.env == 'test' | |
| - | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| end | |
| set_table_name :cms_pages | |
app/models/cms/revision.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| class Cms::Revision < ActiveRecord::Base | |
| unless Rails.env == 'test' | |
| - | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| end | |
| set_table_name :cms_revisions | |
app/models/cms/site.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| class Cms::Site < ActiveRecord::Base | |
| unless Rails.env == 'test' | |
| - | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| end | |
| set_table_name :cms_sites | |
app/models/cms/snippet.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| class Cms::Snippet < ActiveRecord::Base | |
| unless Rails.env == 'test' | |
| - | establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| end | |
| set_table_name :cms_snippets | |
config/database.yml
+2
-1
| @@ | @@ -5,7 +5,8 @@ development: |
| database: db/development.sqlite3 | |
| pool: 5 | |
| timeout: 10000 | |
| - | |
| + | |
| + | # config.database_config = 'cms_' |
| cms_development: | |
| adapter: sqlite3 | |
| database: db/cms_development.sqlite3 | |
config/initializers/comfortable_mexican_sofa.rb
+2
-2
| @@ | @@ -55,10 +55,10 @@ ComfortableMexicanSofa.configure do |config| |
| # 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. |
| + | # in a location other than the default databases add a database_config. |
| # Using a prefix of `cms_` will look for a cms_#{Rails.env} definition | |
| # in your database.yml file | |
| - | # config.database_prefix = 'cms_' |
| + | # config.database_config = nil |
| end | |
migrate/01_create_cms.rb b/db/migrate/01_create_cms.rb
+2
-2
| @@ | @@ -1,7 +1,7 @@ |
| class CreateCms < ActiveRecord::Migration | |
| def self.up | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| # -- Sites -------------------------------------------------------------- | |
| create_table :cms_sites do |t| | |
| t.string :label | |
| @@ | @@ -108,7 +108,7 @@ class CreateCms < ActiveRecord::Migration |
| end | |
| def self.down | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| drop_table :cms_sites | |
| drop_table :cms_layouts | |
migrate/upgrades/02_upgrade_to_1_1_0.rb b/db/migrate/upgrades/02_upgrade_to_1_1_0.rb
+2
-2
| @@ | @@ -1,6 +1,6 @@ |
| class UpgradeTo110 < ActiveRecord::Migration | |
| def self.up | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| rename_column :cms_layouts, :cms_site_id, :site_id | |
| rename_column :cms_pages, :cms_site_id, :site_id | |
| rename_column :cms_pages, :cms_layout_id, :layout_id | |
| @@ | @@ -10,7 +10,7 @@ class UpgradeTo110 < ActiveRecord::Migration |
| end | |
| def self.down | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| rename_column :cms_uploads, :site_id, :cms_site_id | |
| rename_column :cms_snippets, :site_id, :cms_site_id | |
| rename_column :cms_blocks, :page_id, :cms_page_id | |
migrate/upgrades/03_upgrade_to_1_2_0.rb b/db/migrate/upgrades/03_upgrade_to_1_2_0.rb
+2
-2
| @@ | @@ -1,6 +1,6 @@ |
| class UpgradeTo120 < ActiveRecord::Migration | |
| def self.up | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| create_table :cms_revisions, :force => true do |t| | |
| t.string :record_type | |
| t.integer :record_id | |
| @@ | @@ -11,7 +11,7 @@ class UpgradeTo120 < ActiveRecord::Migration |
| end | |
| def self.down | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| drop_table :cms_revisions | |
| end | |
| end | |
| \ No newline at end of file | |
migrate/upgrades/04_upgrade_to_1_3_0.rb b/db/migrate/upgrades/04_upgrade_to_1_3_0.rb
+2
-2
| @@ | @@ -1,6 +1,6 @@ |
| class UpgradeTo130 < ActiveRecord::Migration | |
| def self.up | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| add_column :cms_sites, :is_mirrored, :boolean, :null => false, :default => false | |
| add_column :cms_sites, :path, :string | |
| add_column :cms_sites, :locale, :string, :null => false, :default => 'en' | |
| @@ | @@ -12,7 +12,7 @@ class UpgradeTo130 < ActiveRecord::Migration |
| end | |
| def self.down | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| remove_index :cms_sites, :is_mirrored | |
| remove_column :cms_sites, :path | |
| remove_column :cms_sites, :is_mirrored | |
migrate/upgrades/05_upgrade_to_1_4_0.rb b/db/migrate/upgrades/05_upgrade_to_1_4_0.rb
+2
-2
| @@ | @@ -1,6 +1,6 @@ |
| class UpgradeTo140 < ActiveRecord::Migration | |
| def self.up | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| rename_table :cms_uploads, :cms_files | |
| add_column :cms_files, :label, :string | |
| add_column :cms_files, :description, :string, :limit => 2048 | |
| @@ | @@ -23,7 +23,7 @@ class UpgradeTo140 < ActiveRecord::Migration |
| end | |
| def self.down | |
| - | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}" |
| + | ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_config}#{Rails.env}" |
| remove_index :cms_files, [:site_id, :label] | |
| remove_column :cms_files, :description | |
| remove_column :cms_files, :label | |
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb
+3
-3
| @@ | @@ -44,10 +44,10 @@ class ComfortableMexicanSofa::Configuration |
| 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. |
| + | # in a location other than the default databases add a database_config. |
| # Using a prefix of `cms_` will look for a cms_#{Rails.env} definition | |
| # in your database.yml file | |
| - | attr_accessor :database_prefix |
| + | attr_accessor :database_config |
| # Configuration defaults | |
| def initialize | |
| @@ | @@ -65,7 +65,7 @@ class ComfortableMexicanSofa::Configuration |
| @revisions_limit = 25 | |
| @locales = { :en => 'English', :es => 'Español' } | |
| @admin_locale = nil | |
| - | @database_prefix = nil |
| + | @database_config = nil |
| end | |
| end | |
test/unit/configuration_test.rb
+1
-1
| @@ | @@ -17,7 +17,7 @@ class ConfigurationTest < ActiveSupport::TestCase |
| assert_equal 25, config.revisions_limit | |
| assert_equal ({:en => 'English', :es => 'Español'}), config.locales | |
| assert_equal nil, config.admin_locale | |
| - | assert_equal nil, config.database_prefix |
| + | assert_equal nil, config.database_config |
| end | |
| def test_initialization_overrides | |