cjm2671
cjm2671

Reputation: 19486

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 of getting the email address here?

Upvotes: 1

Views: 31

Answers (1)

Zepplock
Zepplock

Reputation: 29165

try @post.user.email, assuming your models have right associations

Upvotes: 3

Related Questions