‘self.abstract_class = true’ does not seem to be working in my Rails 3
project and I am having difficulty debugging the problem. Can anyone
me some pointers as to were I should look for possible conflicts?
In a previous Rails 2 project I used an abstract class SoftDeletableBase
to add soft delete options to my models.
I am now working on a Rails 3 project, and now need to add similar
functionality. I’ve reworked SoftDeletableBase to work with Rails 3
(refactored scope options), but when I go to implement it the system
seems to be ignoring the abstract class declaration.
In trying to debug the problem, I commented out everything but the class
definition and the abstract class definition. Still the problem remains.
This is what I have:
class SoftDeletableBase < ActiveRecord::Base
self.abstract_class = true
class User < SoftDeletableBase
At the console I get:
That is, the table name for the User model is coming back as
“soft_deletable_bases” when it should be “users”.
If I return the model class to ‘User < ActiveRecord::Base’ everything
returns to normal:
I’ve googled ‘rails 3 abstract_class’ but cannot find anyone else with a
similar problem. Therefore, I’m assuming there is something in my
application that is stopping abstract_class from working properly. My
main problem is that I not sure where to look for the root of the