What did I do to my app? (Superclass mismatch?)

It was working before (as far as I can tell), but I freezed_edge and
now…

The first time I load this page, it works fine, the second time I get
the superclass mismatch, the third time (and any subsequent times ) i
get undefined method.

I think this means my class is getting loaded twice?

my model looks like this:

class Quotation < ActiveRecord::Base
has_many :price_breaks
has_many :items, :through => :price_breaks
belongs_to :contact
end

#STI
class Cost < Quotation
end

class Price < Quotation
end

here’s what the third error says:
undefined method `contact’ for #Cost:0xb7936bc8

Cost.contact works in the console…

Cost.contact works in the console…

contact would be available to instances of Cost, so:

my_cost = Cost.new
my_cost.contact

that should work.

Travis Laduz wrote:

Andrew S. wrote:

Cost.contact works in the console…

contact would be available to instances of Cost, so:

my_cost = Cost.new
my_cost.contact

that should work.

it does work in the console, but not on the page…

I just reverted back to revision 4720 and it works like normal again. I
saw something about double loading errors in changeset 4730. Is this
something I should make a ticket about? I don’t know enough rails to
know if something is broken, or if I’m doing something wrong.

Andrew S. wrote:

Cost.contact works in the console…

contact would be available to instances of Cost, so:

my_cost = Cost.new
my_cost.contact

that should work.

it does work in the console, but not on the page…

Chris H. wrote:

can we see your console output because Cost.contact should throw a
NoMethodError exception.

contact is a instance method, not a class method.

example:

class Project < ActiveRecord::Base
has_many :tickets
end

class Ticket < ActiveRecord::base
belongs_to :project
end

Ticket.project
NoMethodError: undefined method project' for Ticket:Class from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1129:inmethod_missing’
from (irb):1

t = Ticket.new
=> #<Ticket:0x257c6e8 @attributes={“created_on”=>nil,
“project_id”=>nil, “title”=>nil}, @new_record=true>

t.project
=> nil

sorry, i mean to say instances of Cost work in the console.

c = Cost.find :first
c.contact

works

speaking of the console, how do you make it load your subclass models
when it first starts?

Loading development environment.

Cost
NameError: uninitialized constant Cost

Quotation
=> Quotation

Cost
=> Cost

Loading development environment.

FooTicket
=> FooTicket

Ticket
=> Ticket

where

class FooTicket < Ticket
end

no problems here. then again, i’m not running edge either.

can we see your console output because Cost.contact should throw a
NoMethodError exception.

contact is a instance method, not a class method.

example:

class Project < ActiveRecord::Base
has_many :tickets
end

class Ticket < ActiveRecord::base
belongs_to :project
end

Ticket.project
NoMethodError: undefined method project' for Ticket:Class from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1129:inmethod_missing’
from (irb):1

t = Ticket.new
=> #<Ticket:0x257c6e8 @attributes={“created_on”=>nil,
“project_id”=>nil, “title”=>nil}, @new_record=true>

t.project
=> nil