SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2006
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Relationship Problem

    Hey all,

    I seem to be getting confused with one of the relationships in a project I have been working on, and wondering if anyone could figure out where I have gone wrong.

    I have the following relationship:

    A Quote can have many "Standard Fields".
    A "Standard Field" can be used by many different quotes

    I used the following relationship: (ManualItems being the standard fields)

    Code:
    class Quote < ActiveRecord::Base
    belongs_to :Project
    has_and_belongs_to_many :ManualItems
    end
    Code:
    class ManualItem < ActiveRecord::Base
    has_and_belongs_to_many :Quotes ,:join_table => "manual_items_quotes"
    end
    The relationship seems to be working, however I have no idea how to add a ManualItem to a Quote. If I have a list of the ManualItems, how do I add them to a quote?

    Cheers

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    @quote.manual_items << @manual_item


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •