[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

get not working

Free Bird

1/18/2009 5:34:00 PM

I have a class Halt. If i type Halt, the output is
>> Halt
=> Halt(id: integer, troute_id: integer, seq: integer, day: integer,
arrival: integer, departure: integer, duration: integer, tnode_id:
integer, mode: string, junction: boolean, distance: integer, created_at:
datetime, updated_at: datetime)

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

can you please suggest why this is happeneing?
--
Posted via http://www.ruby-....

8 Answers

Ryan Davis

1/18/2009 8:32:00 PM

0


On Jan 18, 2009, at 09:34 , Free Bird wrote:

> I have a class Halt. If i type Halt, the output is
>>> Halt
> => Halt(id: integer, troute_id: integer, seq: integer, day: integer,
> arrival: integer, departure: integer, duration: integer, tnode_id:
> integer, mode: string, junction: boolean, distance: integer,
> created_at:
> datetime, updated_at: datetime)

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.


Brian Candler

1/18/2009 10:26:00 PM

0

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)
--
Posted via http://www.ruby-....

Free Bird

1/19/2009 5:37:00 AM

0

I have one db entry:(/db/migrate)

class CreateHalts < ActiveRecord::Migration
def self.up
create_table :halts do |t|
t.integer :troute_id, :null => false
t.integer :seq
t.integer :day
t.integer :arrival
t.integer :departure
t.integer :duration
t.integer :tnode_id, :null => false
t.string :mode
t.boolean :junction
t.integer :distance
t.timestamps
end
execute "alter table halts add constraint fk_halt_troutes foreign
key (troute_id) references troutes(id)"
execute "alter table halts add constraint fk_halt_tnodes foreign key
(tnode_id) references tnodes(id)"
end

def self.down
drop_table :halts
end
end

and i have one model (app/models)

# == Schema Information
# Schema version: 20081211325430
#
# Table name: halts
#
# id :integer(4) not null, primary key
# troute_id :integer(4) not null
# seq :integer(4)
# day :integer(4)
# arrival :integer(4)
# departure :integer(4)
# duration :integer(4)
# tnode_id :integer(4) not null
# mode :string(255)
# junction :boolean(1)
# distance :integer(4)
# created_at :datetime
# updated_at :datetime
#

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)

--
Posted via http://www.ruby-....

Brian Candler

1/19/2009 8:28:00 AM

0

Free Bird wrote:
> 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.
--
Posted via http://www.ruby-....

Mulligan

6/21/2013 9:48:00 PM

0

On Friday, June 21, 2013 5:43:21 PM UTC-4, •RLMeasures wrote:

Anyone who know Mormonism knows it is a perfect pussy cult since in Mormondom's Celestial Kingdom LdS men receive harems of women with perfect bodies to impregnate so that the men can get promoted to "God" and receive their own Earth-like planet to rule over the same as the present God rules over Earth

Jesus does not rule over the earth yet, silly ...

r

6/22/2013 2:46:00 AM

0

In article <b7923407-0ac1-4056-9840-2c5ca9c10e0c@googlegroups.com>, A
Really Really Large Number <quarke.e2@gmail.com> wrote:

> On Friday, June 21, 2013 5:43:21 PM UTC-4, =95RLMeasures wrote:
>
> Anyone who know Mormonism knows it is a perfect pussy cult since in Mormon=
> dom's Celestial Kingdom LdS men receive harems of women with perfect bodies=
> to impregnate so that the men can get promoted to "God" and receive their =
> own Earth-like planet to rule over the same as the present God rules over E=
> arth
>
> Jesus does not rule over the earth yet, silly ...

? nada

Mulligan

6/22/2013 2:24:00 PM

0

On Friday, June 21, 2013 10:45:37 PM UTC-4, •RLMeasures wrote:
> In article <b7923407-0ac1-4056-9840-2c5ca9c10e0c@googlegroups.com>, A Really Really Large Number <quarke.e2@gmail.com> wrote: > On Friday, June 21, 2013 5:43:21 PM UTC-4, =95RLMeasures wrote: > > Anyone who know Mormonism knows it is a perfect pussy cult since in Mormon= > dom's Celestial Kingdom LdS men receive harems of women with perfect bodies= > to impregnate so that the men can get promoted to "God" and receive their = > own Earth-like planet to rule over the same as the present God rules over E= > arth > > Jesus does not rule over the earth yet, silly ... • nada

no, you definitely posted a reply.
you don't have to put 'nothing' there, just simply don't click and send a reply.

r

6/22/2013 8:39:00 PM

0

In article <f7098c93-b9a3-4fec-b1a1-7d6c54fd28ec@googlegroups.com>, A
Really Really Large Number <t2judgment@gmail.com> wrote:

> On Friday, June 21, 2013 10:45:37 PM UTC-4, =95RLMeasures wrote:
> > In article <b7923407-0ac1-4056-9840-2c5ca9c10e0c@googlegroups.com>, A Rea=
> lly Really Large Number <quarke.e2@gmail.com> wrote: > On Friday, June 21, =
> 2013 5:43:21 PM UTC-4, =3D95RLMeasures wrote: > > Anyone who know Mormonism=
> knows it is a perfect pussy cult since in Mormon=3D > dom's Celestial King=
> dom LdS men receive harems of women with perfect bodies=3D > to impregnate =
> so that the men can get promoted to "God" and receive their =3D > own Earth=
> -like planet to rule over the same as the present God rules over E=3D > art=
> h > > Jesus does not rule over the earth yet, silly ... =95 nada
>
> no, you definitely posted a reply.
> you don't have to put 'nothing' there, just simply don't click and send a r=
> eply.

*** bananas