How do I get the email from an ID when using devise?
So let's say I've got a hypothetical:
@post.user_id
where User has_many posts and I'm using devise,
I'd like to do something like:
@post.user_id.email but this fails; what's the elegant way开发者_StackOverflow社区 of getting the email address here?
try @post.user.email
, assuming your models have right associations
精彩评论