Another question asked about attributes, but I would like to extend the question to associations.
Say I have a simple blogging model
class Discussion < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :discussion
end
Discussion has a #closed? boolean state. I would like to block all entry points to add more comments to a closed discussion. For example,
discussion.comments << Comment.new
discussion.comments.create(:text => 'Something')
and any others that may exist...
Thanks,
-Jason