Files

Class Index [+]

Quicksearch

ActiveRecord::Inheritance

Private Instance Methods

ensure_proper_type() click to toggle source

Sets the attribute used for single table inheritance to this class name if this is not the ActiveRecord::Base descendant. Considering the hierarchy Reply < Message < ActiveRecord::Base, this makes it possible to do Reply.new without having to set Reply = "Reply" yourself. No such attribute would be set for objects of the Message class in that example.

     # File lib/active_record/inheritance.rb, line 167
167:     def ensure_proper_type
168:       klass = self.class
169:       if klass.finder_needs_type_condition?
170:         write_attribute(klass.inheritance_column, klass.sti_name)
171:       end
172:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.