Fixtures rejecting reference to 'belongs_to' association

I have a stock-related rails app, and I want to test the Price model.
Each
price object represents daily price
data for a single Equity, which in turn belongs to a single Issuer.
I’ve
run the test with the following fixtures and get this
error:

1) Error:

test_the_truth(PriceTest):
ActiveRecord::StatementInvalid: PGError: ERROR: column “equity” of
relation
“prices” does not exist
LINE 1: INSERT INTO “prices” (“equity”, “dat”, “opn”, “hgh”, “low”, …
^
: INSERT INTO “prices” (“equity”, “dat”, “opn”, “hgh”, “low”, “cls”,
“vol”,
“created_at”, “updated_at”, “id”) VALUES (‘sprint_common’, ‘2010-01-04’,
3.71, 3.92, 3.7, 3.9, 59299500, ‘2011-06-07 19:49:44’, ‘2011-06-07
19:49:44’, 1014512129)

/home/ded/.rvm/gems/ruby-1.9.2-p180@rails303/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract_adapter.rb:202:in
`rescue in log’

Here is what the fixtures look like:
==================== prices.yml ====================
p_01_04:
equity: sprint_common
dat: 2010-01-04
opn: 3.71
hgh: 3.92
low: 3.7
cls: 3.9
vol: 59299500

p_01_05:
equity: sprint_common
dat: 2010-01-05
opn: 3.92
hgh: 4.2
low: 3.9
cls: 4.13
vol: 95552600

===================== equities.yml =============================
sprint_common:
rawsym: s
sym: S
xch: NYSE
issuer: sprint
earliest: 2005-08-16
latest: 2010-12-31

====================== issuers.yml =============================
sprint:
cik: 10830
name: Sprint Nextel Corporation
sic: 4813
stinc: KS
fy_mo: 12
fy_day: 31

I’ve read the Fixtures document, which indicates that this ought to
work.
But I’ve also read that
having a foreign key somehow keeps fixtures from loading. I have
defined a
foreign key constraint in
one of my migrations from the prices to equities tables.

Is it the foreign key that’s causing the problem? If so, is there any
work
around without deleting the foreign keys?

Thanks,

On 7 June 2011 21:42, ddoherty03 [email protected] wrote:

LINE 1: INSERT INTO “prices” (“equity”, “dat”, “opn”, “hgh”, “low”, …
What do your has_many and belongs_to relationships look like in the
models? What columns are present in the tables?

Colin

Colin,

======================== price.rb ===========================
class Price < ActiveRecord::Base
belongs_to :equities

end
========================equitiy.rb==========================
class Equity < ActiveRecord::Base
after_initialize :clean_up
after_update :clean_up

belongs_to :issuer
has_many :prices

end
=======================issuer.rb=============================
class Issuer < ActiveRecord::Base
after_initialize :clean_up
after_update :clean_up

validates_uniqueness_of :cik

has_many :filings
has_many :equities
has_many :former_names

end

On 7 June 2011 22:00, ddoherty03 [email protected] wrote:

Colin,
======================== price.rb ===========================
class Price < ActiveRecord::Base
belongs_to :equities

That should be :equity, singular

Colin

Thanks, Colin. That did it. You 'da man.

Snow blindness strikes again.

Regards,