Fixing deprecation warning for nil columns in Rails 4.2.beta1

This commit is contained in:
Tommy Fisher 2014-08-25 15:43:48 -07:00
parent 6f2a610150
commit de22cb5e8c
2 changed files with 11 additions and 1 deletions

View File

@ -542,7 +542,7 @@ module SimpleForm
end
def find_attribute_column(attribute_name)
if @object.respond_to?(:column_for_attribute)
if @object.respond_to?(:column_for_attribute) && @object.has_attribute?(attribute_name)
@object.column_for_attribute(attribute_name)
end
end

View File

@ -130,6 +130,16 @@ class User
Column.new(attribute, column_type, limit)
end
def has_attribute?(attribute)
case attribute.to_sym
when :name, :status, :password, :description, :age,
:credit_limit, :active, :born_at, :delivery_time,
:created_at, :updated_at, :lock_version, :home_picture,
:amount, :attempts, :action, :credit_card, :uuid then true
else false
end
end
def self.human_attribute_name(attribute, options = {})
case attribute
when 'name'