Methods
Attributes
[RW] | original_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.
Source: show
# File activerecord/lib/active_record/attribute_methods/primary_key.rb, line 15 def primary_key @primary_key ||= reset_primary_key end
Attribute writer for the primary key column
Source: show
# File activerecord/lib/active_record/attribute_methods/primary_key.rb, line 52 def primary_key=(value) @quoted_primary_key = nil @primary_key = value end
Returns a quoted version of the primary key name, used to construct SQL statements.
Source: show
# File activerecord/lib/active_record/attribute_methods/primary_key.rb, line 20 def quoted_primary_key @quoted_primary_key ||= connection.quote_column_name(primary_key) end
Sets the name of the primary key column to use to the given value, or (if the value is nil or false) to the value returned by the given block.
class Project < ActiveRecord::Base set_primary_key "sysid" end
Source: show
# File activerecord/lib/active_record/attribute_methods/primary_key.rb, line 64 def set_primary_key(value = nil, &block) @quoted_primary_key = nil @primary_key ||= '' self.original_primary_key = @primary_key value &&= value.to_s self.primary_key = block_given? ? instance_eval(&block) : value end