The database is populated. And code was working. But recently it stop
working.
If i type Halt.get, this is the output:
Halt.get(1)
NoMethodError: undefined method `get' for #<Class:0xb7025de8>
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in
`method_missing'
from (irb):3
presumably Halt is both a method Halt() and a class... we can only guess since you don't provide any code.
The database is populated. And code was working. But recently it stop
working.
If i type Halt.get, this is the output:
Halt.get(1)
In this case you're trying to execute the #get class method on the Halt class. That's what the parser sees at least. I'm guessing (again) that you don't have a #get class method and you're instead expecting to call the #get instance method on whatever the #Halt method returns. If you want to ensure that you're calling your method, add parens:
Halt().get(1)
I don't think it is a good design to have an argless global method with the same name as the class. you get confusion like the above.
NoMethodError: undefined method `get' for #<Class:0xb7025de8>
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in
`method_missing'
from (irb):3
can you please suggest why this is happeneing?
Did you mean Halt.find(1) ?
At ar.rubyonrails.com I don't see any "get" method (either class or
instance)
class Halt < ActiveRecord::Base
belongs_to :troute
belongs_to :tnode
validates_presence_of :troute_id, :tnode_id
end
earlier, after populating database,
Halt.get(1) was working.
Brian Candler wrote:
Free Bird wrote:
If i type Halt.get, this is the output:
Halt.get(1)
NoMethodError: undefined method `get' for #<Class:0xb7025de8>
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:1833:in
`method_missing'
from (irb):3
can you please suggest why this is happeneing?
Did you mean Halt.find(1) ?
At ar.rubyonrails.com I don't see any "get" method (either class or
instance)
earlier, after populating database,
Halt.get(1) was working.
How sure are you? I also use activerecord-2.2.2, and 'get' just gives
NoMethodError. I have also checked through the gem source and find no
'def get' or 'def self.get'.
If it did work at one time, then I think you must either have installed
some plugin, or defined your own 'get' class method.