diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-17 04:22:17 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-01-17 06:39:23 +0300 |
commit | 4c305d4dd65643c30471eee5da580f27d87b5f2c (patch) | |
tree | f118fc09ca8ede6664fe0a0ef3d3bc6bb4a79bca /app | |
parent | b9d09a0c5ee43a58f2c19b37f590b2124bb10a25 (diff) |
Validate application settings only if column exists
Diffstat (limited to 'app')
-rw-r--r-- | app/models/application_setting.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index d9c73559098..aed4068f309 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -1,6 +1,7 @@ class ApplicationSetting < ActiveRecord::Base validates :home_page_url, allow_blank: true, - format: { with: URI::regexp(%w(http https)), message: "should be a valid url" } + format: { with: URI::regexp(%w(http https)), message: "should be a valid url" }, + if: :home_page_url_column_exist def self.current ApplicationSetting.last @@ -15,4 +16,8 @@ class ApplicationSetting < ActiveRecord::Base sign_in_text: Settings.extra['sign_in_text'], ) end + + def home_page_url_column_exist + ActiveRecord::Base.connection.column_exists?(:application_settings, :home_page_url) + end end |