New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrectly using parent class table_name when specifying self.table_name explicitly. #4578
Comments
See https://github.com/jensb1/test_4578 test.rb
Backtrace:
|
didn't write so, but this works in 3.1.3 |
Out of curiosity, why would you do this? If there is no A table, you should set the class to be abstract. If there is an A and a B table, you should make the B model inherit from AR::Base. |
I think this is causing me a problem in my paper_trail gem (used for versioning model data), specifically paper-trail-gem/paper_trail#125 and paper-trail-gem/paper_trail#128. Most of the time paper_trail stores versions in a table called People set this up as described in the Custom Version Classes section in the README (sorry no link directly to the line number). PaperTrail then sets it up like this. However the custom table name of a subclass of paper_trail's version class is ignored in Rails 3.2, which means Rails cannot find the table. Is this easy to fix? I'd be happy to have a go if you can point me in the right direction. |
I think the problem is ActiveRecord assumes a subclass of an AR model will be using STI. This is not true in my case. Hmm, having said that, the |
Is this still an issue? Any thoughts on this @tenderlove / @josevalim? |
Not for me anyway, "workaround" exists. 4 maj 2012 kl. 21:56 skrev Isaac Sanders
|
@jensb1 Would you mind closing this then? |
This is still an issue for me and is keeping me from upgrading a couple apps to 3.2. I can't use the abstract class workaround for these apps since I'm inheriting from a class that's inside a gem and need to change the table name along with some other methods from the parent class. |
class A < ActiveRecord::Base
end
clas B < A
self.table_name = 'b'
end
B.first will try to "select * from a" instead of 'select * from b'
The text was updated successfully, but these errors were encountered: