I tried to post this earlier but it didn’t show? Happened a couple
times now.
I hate having to ask this but my eyeballs are spinning and I seem to be
getting some odd behavior.
a bit of the schema:
create_table “orders”, :force => true do |t|
t.column “billing_address_id”, :integer
…
end
single table inheritance here… AddressBilling & AddressShipping
create_table “addresses”, :force => true do |t
t.column “type”, :string, :limit => 20
…
end
which of these pairs is correct?
class Order < ActiveRecord::Base
has_one :billing_address,
:class_name => “AddressBilling”
end
class AddressBilling < Address
belongs_to :order
end
------- OR ----------------
class Order < ActiveRecord::Base
belongs_to :billing_address,
:class_name => “AddressBilling”
end
class AddressBilling < Address
has_one :order
end
I thought the first was the correct but I’m a noob and neither seem to
be working as I’d expect.
When I do this in the controller:
@orders = Order.find(:all)
then in the view:
<% @orders.each do |order| %>
that works fine but then if I do this:
<% @orders.each do |order| %>
I get an error about billing address being a nil object? Yes the
billing address is there with the correct id.
seems odd to me… any help greatly appreciated and thanks in advance!
Tim