Hi,
I’ve got two postgres tables:
CREATE TABLE prodotti (it’s a products table)
(
id serial NOT NULL,
descrizione varchar NOT NULL,
client_id int8 NOT NULL,
CONSTRAINT prodotti_pkey PRIMARY KEY (id)
)
WITHOUT OIDS;
ALTER TABLE prodotti OWNER TO user;
CREATE TABLE prezzi_prodotti (it’s a product’s prices table)
(
id serial NOT NULL,
prezzo_unitario numeric NOT NULL,
annotazioni varchar,
prodotti_id int4 NOT NULL,
CONSTRAINT prezzi_prodotti_pkey PRIMARY KEY (id),
CONSTRAINT prezzi_prodotti_prodotti_id_fkey FOREIGN KEY
(prodotti_id) REFERENCES prodotti (id) ON UPDATE CASCADE ON DELETE
CASCADE
)
WITHOUT OIDS;
ALTER TABLE prezzi_prodotti OWNER TO user;
mapped on: prezzi_prodotti.rb
1 class PrezziProdotti < ActiveRecord::Base
2 set_table_name “prezzi_prodotti”
3 belongs_to :prodotti
and on: prodotti.rb
1 class Prodotti < ActiveRecord::Base
2 set_table_name “prodotti”
3 has_many :prezzi_prodotti
when I try to retrieve the product prices from a searched product I get:
irb(main):004:0> p = Prodotti.find(1)
=> #<Prodotti:0xb778fab8 @attributes={“client_id”=>“43”,
“descrizione”=>“product description”, “id”=>“1”}>
irb(main):005:0> p.prezzi_prodotti
NameError: uninitialized constant PrezziProdottus
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.3/lib/active_support/dependencies.rb:195:in
const_missing' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/associations/association_proxy.rb:12:in
initialize’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/associations/has_many_association.rb:5:in
eval' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/associations/association_proxy.rb:12:in
initialize’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/associations/has_many_association.rb:5:in
initialize' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/associations.rb:735:in
new’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/associations.rb:735:in
prezzi_prodotti' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.0/lib/active_record/associations.rb:731:in
prezzi_prodotti’
from (irb):5
my guess is:
NameError: uninitialized constant PrezziProdottus
is the point, someway the name class is being messed up… like he
mind to pluralize even if I’ve specified the set_table_name clause.
I’ve never experienced something like this. Can someone help me?
Thanks,
Enrico
–
“The only thing necessary for the triumph of evil
is for good men to do nothing”
Edmund Burke