I understand how STI works, in that I have say a Post model that
contains posts on a forum and several sub-posts like
'ordinaryUserPost' and 'adminUserPost' etc.
Now, I want to define the same method in each of the sub-posts, but
the method would do something different in each case, eg
class Post < ActiveRecord::Base
class AdminUserPost < Post
class ordinaryUserPost < Post
(yes its a silly example). Now in my thread controller I do Post.find
(:all) and it gives me a list of posts I need to render, but they are
'Post' objects, not AdminUserPost or OrdinaryUserPost - so I cannot
just get my background_color method! I would have to do a find on
each type of user post separately ...
Is there anyway I can do:
And in the resultant array get a list of AdminUserPost and
OrdinaryUserPost objects instead of Post objects?