read_attribute_before_type_cast

read_attribute_before_type_cast(attr_name) Instance Public methods Returns the value of the attribute identified by attr_name before typecasting and deserialization. class Task < ActiveRecord::Base end task = Task.new(id: '1', completed_on: '2012-10-21') task.read_attribute('id') # => 1 task.read_attribute_before_type_cast('id') # => '1' task.read_attribute('completed_on') # => Sun, 21 Oct 2012 task.read_attribute_b

attribute_method?

attribute_method?(attribute) Instance Public methods 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

attribute_names

attribute_names() Instance Public methods Returns an array of column names as strings if it's not an abstract class and table exists. Otherwise it returns an empty array. class Person < ActiveRecord::Base end Person.attribute_names # => ["id", "created_at", "updated_at", "name", "age"]

class_method_defined_within?

class_method_defined_within?(name, klass, superklass = klass.superclass) Instance Public methods

dangerous_class_method?

dangerous_class_method?(method_name) Instance Public methods A class method is 'dangerous' if it is already (re)defined by Active Record, but not by any ancestors. (So 'puts' is not dangerous but 'new' is.)

instance_method_already_implemented?

instance_method_already_implemented?(method_name) Instance Public methods Raises a ActiveRecord::DangerousAttributeError exception when an Active Record method is defined in the model, otherwise false. class Person < ActiveRecord::Base def save 'already defined by Active Record' end end Person.instance_method_already_implemented?(:save) # => ActiveRecord::DangerousAttributeError: save is defined by ActiveRecord Person.instance_method_already_implemented?(:name) # =&

dangerous_attribute_method?

dangerous_attribute_method?(method_name) Instance Public methods

define_method_attribute

define_method_attribute(attr_name) Instance Public methods

primary_key

primary_key() Instance Public methods Defines the primary key field â can be overridden in subclasses. Overwriting will negate any effect of the primary_key_prefix_type setting, though.

primary_key=

primary_key=(value) Instance Public methods Sets the name of the primary key column. class Project < ActiveRecord::Base self.primary_key = 'sysid' end You can also define the primary_key method yourself: class Project < ActiveRecord::Base def self.primary_key 'foo_' + super end end Project.primary_key # => "foo_id"