instance method id

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

id()

A model instance’s primary key is always available as model.id whether you name it the default ‘id’ or set it to something else.

Source
# File activerecord/lib/active_record/base.rb, line 2494
      def id
        attr_name = self.class.primary_key
        column = column_for_attribute(attr_name)

        self.class.send(:define_read_method, :id, attr_name, column)
        # now that the method exists, call it
        self.send attr_name.to_sym

      end

Defined in activerecord/lib/active_record/base.rb line 2494 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Base

Type at least 2 characters to search.

↑↓ navigate · open · esc close