I followed screencast on rubyonrails.org (creating a blog).
I have the following models:
comment.rb
class Comment < ActiveRecord::Base belongs_to :post validates_presence_of :body
post.rb
class Post < ActiveRecord::Base validates_presence_of :body, :title has_many :comments end
Relations between the models work fine, except for one thing - when I delete a post entry, I would expect RoR to delete all related comment entries. I understand that ActiveRecords is database independent, so there is no built-in way to create foreign keys, relationships, ON DELETE, ON UPDATE. So, is there a way to do this (maybe RoR itself could take care of deleting related comments?)?
ruby-on-rails rails-activerecord database-relations
Jakub LΓ©dl Dec 13 '09 at 15:08 2009-12-13 15:08
source share