[Rails] Re: STI and touch'ing of dates

Johan Sörensen johans at gmail.com
Wed Dec 15 23:19:32 GMT 2004


Wow, now I once again feel stupid. 
I totally forgot that I had something that updates a column in
ForumThread whenever someone replies, thus triggering the
before_update callback.

/me blushes

-- johan


On Wed, 15 Dec 2004 16:23:26 +0100, Johan Sörensen <johans at gmail.com> wrote:
> I noticed this when I used the Touch mixin, but it seems to be more of
> a single table inheritance issue (could also be an issue with my head
> t hough). I'm getting the same error with my own touch methods, as
> seen below:
> 
> I have the following classes
> 
> class Post < ActiveRecord::Base
>   def before_create
>         self.updated_at = Time.now
>         self.created_at = Time.now
>   end
> end
> 
> class ForumThread < Post
>   has_many :replies
> end
> 
> class Reply < Post
>   belongs_to :forum_thread
> end
> 
> Now, if I create a ForumThread or add a Reply all is good. However,
> when I edit a Reply the ForumThreads (ie the parent to the Reply)
> updated_at is also updated (aswell as the Reply.updated_at but thats
> obviously intended)!
> 
> Is this a bug somewhere? Or am I missing some feature/concept in the
> inheritance model?
> 
> -- johan
> 
> --
> Johan Sørensen
> Professional Futurist
> www.johansorensen.com
> 


-- 
Johan Sørensen
Professional Futurist
www.johansorensen.com


More information about the Rails mailing list