-
Notifications
You must be signed in to change notification settings - Fork 24
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
STI class not inheriting attributes from citier child class #67
Comments
class Content < ActiveRecord::Base
acts_as_citier
validates :page_id, presence: true
end
class CommonField < Content
acts_as_citier
self.inheritance_column = 'sub-type'
end
class Text < CommonField
end I'm also having problems with STI. In my case, STI child class able to inherit attributes from both Content and CommonField but when i save it, Content is saving the type of STI class as nil rather than CommonField.
|
I have exactly the same problem as @maliakmal, I had not read this post before so I started a new issue |
This gem does not seem to be maintained, in the end i used Multiple Table Inheritance with AR. |
@zubairshams, is this a gem ? can you paste the link to it ? |
@gustavobap No i'm not using any gem, you can achieve this without the gem. But there are some gem for achieving this. https://github.com/hzamani/acts_as_relation But i recommend you should do this without using any gem. There is a great help to achieve Multiple table inheritance in this article. This way you can also customize it according to your needs. |
Hi, @zubairshams thanks for the answer, I saw other solutions but they are based on simulating MTI, I want to actually inherit the model classes like with Rails STI. I ended up with a very simple workaround, in @maliakmal example the only modification would be:
|
Hi guys I have the following classes set up:
When I try to instantiate an object of Company I get an object with all the attributes of Company class and Contact however if I try to instantiate an object of class Operator I only get the attributes of class Contact and not of Company which I'm inheriting from. I've dropped and created my citier views however still can't resolve this. Please do help.
The text was updated successfully, but these errors were encountered: