开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜