Travis Laduz
2006-Aug-17 22:08 UTC
[Rails] 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... -- Posted via http://www.ruby-forum.com/.
Andrew Stone
2006-Aug-17 22:32 UTC
[Rails] what did I do to my app? (Superclass mismatch?)
> > > 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. -- Andrew Stone -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060817/e591e4dc/attachment.html
Travis Laduz
2006-Aug-17 22:49 UTC
[Rails] Re: what did I do to my app? (Superclass mismatch?)
Andrew Stone 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... -- Posted via http://www.ruby-forum.com/.
Travis Laduz
2006-Aug-17 22:57 UTC
[Rails] Re: what did I do to my app? (Superclass mismatch?)
Travis Laduz wrote:> Andrew Stone 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. -- Posted via http://www.ruby-forum.com/.
Chris Hall
2006-Aug-17 23:09 UTC
[Rails] Re: what did I do to my app? (Superclass mismatch?)
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.projectNoMethodError: 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 On 8/17/06, Travis Laduz <tladuke@amidoncorp.com> wrote:> Andrew Stone 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... > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Travis Laduz
2006-Aug-17 23:23 UTC
[Rails] Re: Re: what did I do to my app? (Superclass mismatch?)
Chris Hall 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 > => nilsorry, 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.>> CostNameError: uninitialized constant Cost>> Quotation=> Quotation>> Cost=> Cost -- Posted via http://www.ruby-forum.com/.
Chris Hall
2006-Aug-17 23:40 UTC
[Rails] Re: Re: what did I do to my app? (Superclass mismatch?)
Loading development environment.>> FooTicket=> FooTicket>> Ticket=> Ticket where class FooTicket < Ticket end no problems here. then again, i''m not running edge either. On 8/17/06, Travis Laduz <tladuke@amidoncorp.com> wrote:> Chris Hall 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 > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >