Suppose I have an Comment model that belongs_to a Post model.
I want to make it so that creation of a new Comment instance (whether by new, create, find_or_create_by_x, etc.) will fail (preferably raise an exception) unless the Post is set immediately (either by passing it in as a parameter or by always referencing the post when creating a comment, e.g. post.comments.new or post.comments.create).
I want to do this because I want to set some default values in the comment object which are based on the post...so the post reference needs to be immediately valid.
What is the best way to accomplish this? Thanks.