Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
Fixed an issue with has_settings if the app database hasn't been crea…
Browse files Browse the repository at this point in the history
…ted yet.
  • Loading branch information
James Cook committed Mar 12, 2009
1 parent d8f00b2 commit 4ef5e7f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion vendor/plugins/has_settings/lib/has_settings.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 4ef5e7f

Please sign in to comment.