This project is archived and is in readonly mode.
Namespaced models and STI
When using namespaced models and STI, ActiveRecord stores the demodulized name of the class. This work if all the class in the STI hierarchy are in the same namespace but will break otherwise.
class CollectionItem < ActiveRecord::Base; end class ComicCollection::Item < CollectionItem; end item = ComicCollection::Item.new item.type # => 'Item' item2 = CollectionItem.find(item.id) # raise an error because can't find class Item
This patch add an option that when enable (it is by default) will store the full class name.
Comments and changes to this ticket
Just FYI there are three issues remaining:
- HasManyThroughAssociation#build_sti_condition, as Jonathan mentioned above.
- ActiveRecord::Base#type_name_with_module adds the parent name, resulting in an annoying ruby warning.
- You can't create migration-specific STI models because the migration name will be saved to the #type value too. (see the rails core ML post.
- State changed from open to resolved
(from [72483c0d4c1e4ea794919974100acc2f255f6fd2]) Add ActiveRecord::Base.sti_name that checks ActiveRecord::Base#store_full_sti_class? and returns either the full or demodulized name. [rick] [#114 state:resolved]
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>