Hi,
I have these two ActiveRecord models: UserEvent and CoordinateEvent.
The models are extended with the module MapEvent. MapEvent includes some
class methods and some instance methods.
Now, I want both models to use ActiveRecord''s serialize
(http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001984).
My MapEvent looks something like the following. I simply can''t figure
where to put "serialize :column_name":
[code]
module MapEvent
def self.included(base)
base.extend(ClassMethods)
end
def a_method
end
module ClassMethods
def another_method
end
end
end
[/code]
How do I call the serialize method from the above context?
An extra question:
Also, it suddenly hit me, that instead of a module I could write
MapEvent as a class that inherits from ActiveRecord instead of a module
- and then let UserEvent and CoordinateEvent inherit from MapEvent?
Would you recommend this? Generally speaking, when should you use
mixins/module and when you use inheritance?
Hope my questions are clear. Thanks in advance!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---