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

**URL:** <https://www.ruby-forum.com/t/what-did-i-do-to-my-app-superclass-mismatch/65408>\
**Category:** Rails\
**Created:** [August 18, 2006, 12:08am UTC](https://www.ruby-forum.com/t/what-did-i-do-to-my-app-superclass-mismatch/65408 "2006-08-18T00:08:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tladuke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tladuke](https://www.ruby-forum.com/u/tladuke)\
**Post date:** [August 18, 2006, 12:08am UTC](https://www.ruby-forum.com/t/what-did-i-do-to-my-app-superclass-mismatch/65408/1 "2006-08-18T00:08:25Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![tladuke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tladuke](https://www.ruby-forum.com/u/tladuke)\
**Post date:** [August 18, 2006, 12:33am UTC](https://www.ruby-forum.com/t/what-did-i-do-to-my-app-superclass-mismatch/65408/2 "2006-08-18T00:33:34Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![tladuke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tladuke](https://www.ruby-forum.com/u/tladuke)\
**Post date:** [August 18, 2006, 12:57am UTC](https://www.ruby-forum.com/t/what-did-i-do-to-my-app-superclass-mismatch/65408/3 "2006-08-18T00:57:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tladuke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tladuke](https://www.ruby-forum.com/u/tladuke)\
**Post date:** [August 18, 2006, 12:49am UTC](https://www.ruby-forum.com/t/what-did-i-do-to-my-app-superclass-mismatch/65408/4 "2006-08-18T00:49:41Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![tladuke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tladuke](https://www.ruby-forum.com/u/tladuke)\
**Post date:** [August 18, 2006, 1:23am UTC](https://www.ruby-forum.com/t/what-did-i-do-to-my-app-superclass-mismatch/65408/5 "2006-08-18T01:23:02Z")

</div>

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:in`method\_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

---

<div class="post-metadata">

**Author:** ![tladuke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tladuke](https://www.ruby-forum.com/u/tladuke)\
**Post date:** [August 18, 2006, 1:42am UTC](https://www.ruby-forum.com/t/what-did-i-do-to-my-app-superclass-mismatch/65408/6 "2006-08-18T01:42:40Z")

</div>

Loading development environment.

> > FooTicket  
> > =\> FooTicket
> 
> > Ticket  
> > =\> Ticket

where

class FooTicket \< Ticket  
end

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

---

<div class="post-metadata">

**Author:** ![tladuke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df788c/32.png) [@tladuke](https://www.ruby-forum.com/u/tladuke)\
**Post date:** [August 18, 2006, 1:09am UTC](https://www.ruby-forum.com/t/what-did-i-do-to-my-app-superclass-mismatch/65408/7 "2006-08-18T01:09:37Z")

</div>

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:in`method\_missing’  
> > from (irb):1
> 
> > t = Ticket.new  
> > =\> #\<Ticket:0x257c6e8 @attributes={“created\_on”=\>nil,  
> > “project\_id”=\>nil, “title”=\>nil}, @new\_record=true\>
> 
> > t.project  
> > =\> nil
