class Followup < ActiveRecord::Base
belongs_to :post
belongs_to :comment
end
This model should have only a message or comment, but only one of two.
Here's rspec for what I'm trying to do:
it "should be impossible to have both a comment and a post" do
followup = Followup.make
followup.comment = Comment.make
followup.should be_valid
followup.post = Post.make
followup.should_not be_valid
end
I can see a bunch of solutions to do this, but what would be the most elegant way to do this?
source
share