instance method
attribute_method?
Ruby on Rails 7.1.6
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 230
def attribute_method?(attribute)
super || (table_exists? && column_names.include?(attribute.to_s.delete_suffix("=")))
end
Defined in activerecord/lib/active_record/attribute_methods.rb line 230
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods::ClassMethods