This project is archived and is in readonly mode.
ActiveRecord ignoring set_table_name on save
-
Kane
i cant confirm this.
could you provide more details? maybe the code of your model?
-
José Valim
- State changed from new to needs-more-info
- Importance changed from to Low
-
Nicholas Faiz
I've created a demo app for the problem here: http://github.com/biv/r3-bug-in-table-name . Apologies, I should have put more information on the ticket originally - I was rushed at the time.
Note, I'm running this using Postgresql 9.0 beta and using ruby 1.8.7.
The problem occurs when using inheritance on models. In this case a Mob::User < ActiveRecordBase exists in lib/mob. The model foo.rb extends it and sets a table name. When saving a foo the validation sequence is triggered. The validation in Mob::User looks for a table name 'users', despite a Foo being created (with a table name of 'other_foos').
Let me know if you need any further info..
-
Kane
Im not quite sure that this worked in any previous versions.
normally AR assumes STI if you inherit from another model.
if you dont want that you could declare the parent model as abstract.class MyModel < ActiveRecord::Base self.abstract_class = true endRails cant do MTI.
-
Nicholas Faiz
Thanks. It did work without setting abstract_class in Rails 2.2.2 (have a working app which uses this lib there). But the abstract_class property fixes it. Should have thought to try that.
-
Neeraj Singh
- State changed from needs-more-info to resolved