Merge pull request #1126 from wless1/master
Fixing deprecation warning for nil columns in Rails 4.2.beta1
This commit is contained in:
commit
29f8f768f1
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue