instance method
attribute_method?
Ruby on Rails edge
Since v3.2.22.5Signature
attribute_method?(attribute)
Returns true if attribute is an attribute method and table exists, false otherwise.
“‘ class Person < ActiveRecord::Base end
Person.attribute_method?(‘name’) # => true Person.attribute_method?(:age=) # => true Person.attribute_method?(:nothing) # => false “‘
Parameters
-
attributereq
Source
# File activerecord/lib/active_record/attribute_methods.rb, line 247
def attribute_method?(attribute)
super || (table_exists? && column_names.include?((attribute.is_a?(Symbol) ? attribute.name : attribute.to_s).delete_suffix("=")))
end
Defined in activerecord/lib/active_record/attribute_methods.rb line 247
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods::ClassMethods