开发者

How do I get the email from an ID when using devise?

开发者 https://www.devze.com 2023-04-05 16:56 出处:网络
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:

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

精彩评论

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

关注公众号