Skip to content

Commit

Permalink
Validate application settings only if column exists
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaporozhets committed Jan 17, 2015
1 parent e7f7725 commit 38600e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion 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
Expand All @@ -15,4 +16,8 @@ def self.create_from_defaults
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
2 changes: 1 addition & 1 deletion db/schema.rb
Expand Up @@ -424,14 +424,14 @@
t.integer "notification_level", default: 1, null: false
t.datetime "password_expires_at"
t.integer "created_by_id"
t.datetime "last_credential_check_at"
t.string "avatar"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.boolean "hide_no_ssh_key", default: false
t.string "website_url", default: "", null: false
t.datetime "last_credential_check_at"
t.string "github_access_token"
end

Expand Down

0 comments on commit 38600e3

Please sign in to comment.