This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed an issue with has_settings if the app database hasn't been crea…

…ted yet.
  • Loading branch information...
James Cook
James Cook committed Mar 12, 2009
1 parent d8f00b2 commit 4ef5e7f22e724674663d8039ef14f403d772afb8
Showing with 10 additions and 1 deletion.
  1. +10 −1 vendor/plugins/has_settings/lib/has_settings.rb
@@ -22,7 +22,7 @@ module ClassMethods
# >> w.reload
# >> w.settings["foo"] #=> "bar
def has_settings
if ActiveRecord::Base.connection.table_exists?('has_settings_settings')
if database_setup?
has_one :has_settings_setting, :as => "configurable"
after_save :save_settings

@@ -50,6 +50,15 @@ def has_settings
end
end
end

protected
def database_setup?
begin
connection = ActiveRecord::Base.connection
connection.table_exists?('has_settings_settings') ? true : false
rescue Mysql::Error
end
end
end
end

0 comments on commit 4ef5e7f

Please sign in to comment.