Skip to content
Snippets Groups Projects
Commit 4c305d4d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Validate application settings only if column exists

parent b9d09a0c
No related branches found
No related tags found
No related merge requests found
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
Loading
Loading
@@ -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
Loading
Loading
@@ -424,7 +424,6 @@ ActiveRecord::Schema.define(version: 20150116234544) do
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"
Loading
Loading
@@ -432,6 +431,7 @@ ActiveRecord::Schema.define(version: 20150116234544) do
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
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment