hmm, ok.  I'll add the has many products to my cart.rb file.   Here is my 
current cart index.  
Are you suggesting I nest my product loop in my cart?

Thanks,
Joe

<% @carts.each do |cart| %>
 <tr>
 <td><%= cart.created_at.strftime("%m/%d/%Y") %> | <%= cart.product_id %> 
</td>
 <td><%#= link_to 'Show', cart %></td>
 <td><%#= link_to 'Edit', edit_cart_path(cart) %></td>

 <% if not cart.processing? %>
 <td>| <%= link_to 'Remove', cart, method: :delete, data: { confirm: 'Are 
you sure?' } %> </td>
 <% else %>
 <td> <%= '| Processing order...' %> </td>
 <% end %>
 </tr>
<% end %>





On Thursday, February 9, 2017 at 4:04:25 PM UTC-5, Colin Law wrote:
>
> On 9 February 2017 at 17:49, Joe Guerra <[email protected] 
> <javascript:>> wrote: 
> > I've got a simple cart table with a link to a product id. 
> > 
> > I'd like to grab the values from the product table that match the 
> product id 
> > in the cart, but I'm looping thru the cart in an index view. 
> > So, I wasn't quite sure how to accomplish this. 
>
> Assuming that you have Cart has_many products, and if you haven't then 
> you probably should have, then you can say (if the cart is in @cart) 
>
> @cart.products.each do |product| 
>   # at this point product contains the Product 
> end 
>
> Colin 
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/b043ff4b-b51a-47b8-9724-4dcb886c1c96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to