If your review model looks like this:

class Review
  belongs_to :user
  belongs_to :reviewable, :polymorphic => true
end

You could probably do something like this:

Book.find(1).reviews.each do |r|
  puts r.user.name
end

On Fri, Sep 19, 2008 at 7:10 PM, Becca Girl
<[EMAIL PROTECTED]> wrote:
>
> Please see the above post for the setup of my models.
>
> While trying to figure this out, I put this into script/console:
>
>>> Book.find(1).reviews
>
> => [<#Review id: 2, reviewable_type: "Book", reviewable_id: 1,
> review_user_id: 1>]
>
>
> How can I take the value of review_user_id and get the name of the user
> in the users table?
>
> Thanks!
> --


-- 
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)
João Pessoa, PB, +55 83 8867-7208

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to