I've previously used concerns to extend my models without problems. I'm
now trying to extend all my models in one swell-foop by extending AR
with a concern. In brief, I want to add a class variable to each
individual model using a concern that extends AR. Specifically - I
need to find the where (and how) to define a class variable scoped to a
specific model in my AR extending concern. Is this sane? Possible?
Maybe? This seems like requiring the children to know a specific implementation detail of a parent class via the concern mixin. Instead, I’d provide accessor methods.
Your observations are exactly what I was running into. Good to know I
should focus on class instance variables. Inheritance is a bit of mixed
bag- I want it for all subclasses of my models whose superclass is not
AR::Base.
The link is very helpful, wish I would have seen it earlier. A couple
followups- can you comment on whether some of the approach therein has
been replaced with the use of 'class_attribute'? Also, do you forsee
any issues with using a Concern rather than the extend approach
described there?
At present I've fallen back to just extending individual models (this in
retrospect might be safer in the long run, albeit not as magikal).