Newbie issue, probably:
Background:
Have two tables:
Order
id
Location
id
address1
city
state
(etc.)
Each order has one or more origin and destination locations. (The
order is an order for a transportation company to ship something
Each location can exist on multiple orders.
Have the following link tables:
order_origin_location_link
order_id
location_id
order_destination_location_link
order_id
location_id
Attempted solution
Order.rb:
class Order < ActiveRecord::Base
belongs_to :vendor
belongs_to :customer
has_and_belongs_to_many :origin_location,
:class_name => 'Location',
:join_table => 'order_origin_location_link',
:foreign_key => 'order_id',
:association_foreign_key => 'location_id'
has_and_belongs_to_many :destination_location,
:class_name => 'Location',
:join_table => 'order_destination_location_link',
:foreign_key => 'order_id',
:association_foreign_key => 'location_id'
def add_stop
end
end
order#edit.rhtml
…
When I invoke order#edit, I get
undefined method `address1’ for Location:Class
Can anyone illuminate me where I have gone astray?
Thanks
Ed