Open bemueller opened 8 years ago
Hum, indeed. We miss proper inheritance.
Just checking. This is still a problem right? No support for inheritance?
Well, you can repeat the parent class definition and it will work. But no it won't merge automatically.
A PR would be welcome though.
K. Thanks for the clarification. I think for now that I will just repeat the declaration. Maybe I'll find time in the future for a PR.
Now that there is a PR for it, any chance of getting it merged?
The PR never passed CI.
@byroot fair enough.
This seems to no longer be an issue? I was not aware it could be, tried it, worked.
class SurveyQuestion < ApplicationRecord
typed_store :settings, coder: ActiveRecord::TypedStore::IdentityCoder do |s|
s.string :internal_uid
end
end
class SurveyQuestions::Text < SurveyQuestion
typed_store :settings, coder: ActiveRecord::TypedStore::IdentityCoder do |s|
s.string :input_type, default: "text"
end
end
Then
text_question = SurveyQuestions::Text.new(internal_uid: 1, input_type: "text")
puts JSON.pretty_generate text_question.attributes # { "id": null, "settings": {"input_type": "text", "internal_uid": 1 } }
puts text_question.internal_uid # 1
puts text_question.input_type # text
This may still be an issue with the default coder and not the identity one? Didn't get to check that.
Hi.
Nice framework that you wrote. Unfortunately there's an issue in a single table inheritance environment:
When defining fields for both base and child classes, the the defined columns aren't merged. Hence objects of Bus have getters/setters for :wheels but the type is not checked and the default value is not set automatically.