Adds default values to limits when the db does not have them

This prevents errors when doing rake db:setup (the db has still not
been created but the rails models are loaded)
This commit is contained in:
kikito
2015-09-11 11:32:29 +02:00
parent 7b672d3ecb
commit c399ddf18d
3 changed files with 3 additions and 3 deletions

View File

@@ -147,7 +147,7 @@ class Debate < ActiveRecord::Base
end
def self.title_max_length
@@title_max_length ||= self.columns.find { |c| c.name == 'title' }.limit
@@title_max_length ||= self.columns.find { |c| c.name == 'title' }.limit || 80
end
def self.description_max_length

View File

@@ -34,7 +34,7 @@ class Organization < ActiveRecord::Base
end
def self.name_max_length
@@name_max_length ||= self.columns.find { |c| c.name == 'name' }.limit
@@name_max_length ||= self.columns.find { |c| c.name == 'name' }.limit || 60
end
private

View File

@@ -144,7 +144,7 @@ class User < ActiveRecord::Base
end
def self.username_max_length
@@username_max_length ||= self.columns.find { |c| c.name == 'username' }.limit
@@username_max_length ||= self.columns.find { |c| c.name == 'username' }.limit || 60
end
def show_welcome_screen?