[Rails] STI and touch'ing of dates

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


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


More information about the Rails mailing list