Files

Class/Module Index [+]

Quicksearch

ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods

Public Instance Methods

primary_key() click to toggle source

Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the primary_key_prefix_type setting, though.

# File lib/active_record/attribute_methods/primary_key.rb, line 15
def primary_key
  reset_primary_key
end
primary_key=(value = nil, &block) click to toggle source
Alias for: set_primary_key
quoted_primary_key() click to toggle source

Returns a quoted version of the primary key name, used to construct SQL statements.

# File lib/active_record/attribute_methods/primary_key.rb, line 20
def quoted_primary_key
  @quoted_primary_key ||= connection.quote_column_name(primary_key)
end
set_primary_key(value = nil, &block) click to toggle source

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
# File lib/active_record/attribute_methods/primary_key.rb, line 48
def set_primary_key(value = nil, &block)
  @quoted_primary_key = nil
  define_attr_method :primary_key, value, &block
end
Also aliased as: primary_key=

[Validate]

Generated with the Darkfish Rdoc Generator 2.