On Thu, Aug 6, 2009 at 10:22 AM, Sijo Kg <rails-mailing-l...@andreas-s.net>wrote:
> > Hi > > Assume tables are names, addresses > So the junction table should be addresses_names by default This > can be override if needed.. And the join table wont have id column This > is has_and_belongs_to_many(HABTM) > Have you setup relationships properly If so you can get all the > addresses corresponding to a name by > > example > name = Name.first > name.addresses > > and viceversa > > address = Address.find 1 > address.names > > And better rename your tables to something like contacts and > contact_addresses > > > > Sijo > > > -- > Posted via http://www.ruby-forum.com/. > > > > Hi Sijo thank you I will explain the real need Table 1: agencie id name description 1 agency1 desc1 2 agency2 desc2 Table 2: contract id name description 1 contract1 desc1 2 contract2 desc2 Table 3 : agency_contracts agency_id contract_id 1 1 2 1 1 2 2 2 So form the above table you can find one contract can contain any number or gagencies so i need to display as contract1 agency1 agency2 contract2 agency1 agency2 I think you can under stand inside one contract two agency comes in as it is in agency_contracts table I need to write a ror format query and not in sql query(As my client needs) this is what i need sijo plz help -- Karthik.k Mobile - +91-9894991640 --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---