Dear all,

there are two tables ,one is product, one is location,
product has many location, and location belongs to product, all the
setting in the models i have done, now in the views/show.html.erb, i
want to display the product and its locations, usually we use
@product.locations to get all the locations, acturally,it finds all the
locations based on the id, but now, i have another column which is
item_id in both tables and works as foreign key, so now i want to show
the locations of the product where product.item_id=location.item_id ,
how to do this ?

Thanks

--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Jan 19, 2012 at 10:19 am

    On 19 January 2012 04:19, Daisy Di wrote:
    Dear all,

    there are two tables ,one is product, one is location,
    product has many location, and location belongs to product, all the
    setting in the models i have done, now in the views/show.html.erb, i
    want to display the product and its locations, usually we use
    @product.locations to get all the locations, acturally,it finds all the
    locations based on the id, but now, i have another column which is
    item_id in both tables and works as foreign key, so now i want to show
    the locations of the product where product.item_id=location.item_id ,
    how to do this ?
    This is apparently related to your earlier post, but the function of
    item_id appears to have changed. Please clarify what this item_id
    column is. If it is a foreign key what is it a key to?

    If this is actually the same problem as the previous one please say so
    on one of the threads and say that conversation should be in the other
    one so that we do not have a conversation split over two threads.

    Colin

    --
    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 rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 19, '12 at 4:19a
activeJan 19, '12 at 10:19a
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Daisy Di: 1 post Colin Law: 1 post

People

Translate

site design / logo © 2022 Grokbase