Much like the methods first!, last!, or find_by! there are cases where the context of code you’re in expects an association to be present.
I’d like to get feedback on adding equivalent methods for belongs_to
and has_one
to raise in the case where these associations are expected to exist but don’t.
Example:
class Post
belongs_to :author
end
post = Post.first!
post.author! # should raise if author is not present
I’d be happy to open a PR for this feature assuming this feature is permitted.