views:

61

answers:

1

I am trying to write a simple application and I am stumped!

Here is what I have as a view for users/show/1:

<p>
  <b>User:</b>
  <%=h @user.login %>
</p>

    <% if @user.reviews.empty? %>
     No Analyst Reports yet
    <% else %>
     <% for review in @user.reviews %>
      <%= review.vendor_id %><%= review.summary %><br />
      <hr class="span-5" />

     <% end %>
    <% end %>

I created a relationship where user :has_many reviews and vendor :has_many reviews

So I assume that there should be a value for review.vendor_id, where vendor_id is just automatically created and can be displayed.

Thank you :)

Here is my Reviews model:

class Review < ActiveRecord::Base
  belongs_to :vendor
  belongs_to :user

end

Actually this has been solved, I now need to go through the for-loop and display attributes of vendor....see my other question please! Thanks!

A: 

Does your review model have the corresponding belongs_to :user belongs_to :vendor - ?

Also, when a review is created, have you checked that the vendor_id is filled? check this question: http://stackoverflow.com/questions/753379/how-do-you-set-an-attribute-when-creating-an-activerecord-object

Reuben Mallaby
Yes, to both! I have a belongs to :user and belongs_to :vendorIt appears that the database is in fact storing the vendor_id value in each review....but how do I extract the vendor name and vendor id?
Angela
<%=h review.vendor.id %><%=h review.vendor.name %>
Reuben Mallaby