NoMethodError: private method `to_date'

S

Sukeerthi Adiga

Loading development environment.Time.now.to_date
NoMethodError: private method `to_date' called for Mon Feb 25 12:04:10
+0530 2008:Time
from (irb):1
earlier it use to work fine..
can any one help me whats the prob is?

in terminal it shows like this..

sukeerthi@sukeerthi-desktop:~$ ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
sukeerthi@sukeerthi-desktop:~$
 
7

7stud --

Sukeerthi said:
Loading development environment.Time.now.to_date
NoMethodError: private method `to_date' called for Mon Feb 25 12:04:10
+0530 2008:Time
from (irb):1
earlier it use to work fine..
can any one help me whats the prob is?

in terminal it shows like this..

sukeerthi@sukeerthi-desktop:~$ ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
sukeerthi@sukeerthi-desktop:~$

$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0]


puts Time.now.to_date

--output:--
undefined method `to_date' for Sun Feb 24 23:59:42 -0700 2008:Time
(NoMethodError)


And, pickaxe2 lists no method in the Time class called to_date.
 
S

Shiva Kumaran

just try in console mode :/ruby script/console
it will work


Sukeerthi said:
Loading development environment.Time.now.to_date
NoMethodError: private method `to_date' called for Mon Feb 25 12:04:10
+0530 2008:Time
from (irb):1
earlier it use to work fine..
can any one help me whats the prob is?

in terminal it shows like this..

sukeerthi@sukeerthi-desktop:~$ ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
sukeerthi@sukeerthi-desktop:~$
 
S

Sukeerthi Adiga

7stud said:
Sukeerthi said:
Loading development environment.
Time.now.to_date
Time.now.to_date
NoMethodError: private method `to_date' called for Mon Feb 25 12:04:10
+0530 2008:Time
from (irb):1
earlier it use to work fine..
can any one help me whats the prob is?

in terminal it shows like this..

sukeerthi@sukeerthi-desktop:~$ ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
sukeerthi@sukeerthi-desktop:~$

$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0]


puts Time.now.to_date



so where should i make change so that it should work..
in most of the functions i have written
 
S

Sukeerthi Adiga

Shiva said:
just try in console mode :/ruby script/console
it will work


Sukeerthi said:
Loading development environment.
Time.now.to_date
Time.now.to_date
NoMethodError: private method `to_date' called for Mon Feb 25 12:04:10
+0530 2008:Time
from (irb):1
earlier it use to work fine..
can any one help me whats the prob is?

in terminal it shows like this..

sukeerthi@sukeerthi-desktop:~$ ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
sukeerthi@sukeerthi-desktop:~$

tried no use same error m gettin


sukeerthi@sukeerthi-desktop:/home/workspace/St$ ruby script/console
Loading development environment.
oldcolname==old2 ,newcolname==new2
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
`const_missing':NameError: uninitialized constant TestNameError: undefined local variable or method `time' for
NoMethodError: private method `to_date' called for Mon Feb 25 12:45:18
+0530 2008:Time
from (irb):2
 
D

Deepa Shirur

Sukeerthi said:
Shiva said:
just try in console mode :/ruby script/console
it will work


Sukeerthi said:
Loading development environment.
Time.now.to_date
Time.now.to_date
NoMethodError: private method `to_date' called for Mon Feb 25 12:04:10
+0530 2008:Time
from (irb):1


earlier it use to work fine..
can any one help me whats the prob is?

in terminal it shows like this..

sukeerthi@sukeerthi-desktop:~$ ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
sukeerthi@sukeerthi-desktop:~$

tried no use same error m gettin


sukeerthi@sukeerthi-desktop:/home/workspace/St$ ruby script/console
Loading development environment.
oldcolname==old2 ,newcolname==new2
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
`const_missing':NameError: uninitialized constant TestNameError: undefined local variable or method `time' for
NoMethodError: private method `to_date' called for Mon Feb 25 12:45:18
+0530 2008:Time
from (irb):2

Hi Sukeerthi, Better u change your rails version, Mine is rails 1.2.3,
The problem what you have sent its working fine.

deepac@deepa-UBUNTU-7:~/workspace/srishti$ script/console
Loading development environment.=> #<Date: 4909043/2,0,2299161>
:0)
 
S

Sukeerthi Adiga

Hi Sukeerthi, Better u change your rails version, Mine is rails 1.2.3,
The problem what you have sent its working fine.

deepac@deepa-UBUNTU-7:~/workspace/srishti$ script/console
Loading development environment.
=> #<Date: 4909043/2,0,2299161>
:0)

Okay deepa let me c that..
Thanks for ur reply
 
R

Rick DeNatale

7stud said:
Sukeerthi said:
Loading development environment.
Time.now.to_date
Time.now.to_date
NoMethodError: private method `to_date' called for Mon Feb 25 12:04:10
+0530 2008:Time
from (irb):1


earlier it use to work fine..
can any one help me whats the prob is?

in terminal it shows like this..

sukeerthi@sukeerthi-desktop:~$ ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
sukeerthi@sukeerthi-desktop:~$

$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0]


puts Time.now.to_date
so where should i make change so that it should work..
in most of the functions i have written

Ruby is not Rails!

The problem is that Time#to_date is an extension which Rails makes to
Ruby. That's why it's working for folks who are running this code
under script/console in a Rails project but doesn't work if you run it
under Ruby w/o rails.

In order to use the activesupport extensions you need to:

require 'rubygems'
require 'activesupport'
 
T

Trans

7stud said:
Sukeerthi Adiga wrote:
Loading development environment.
Time.now.to_date
Time.now.to_date
NoMethodError: private method `to_date' called for Mon Feb 25 12:04:10
+0530 2008:Time
from (irb):1
earlier it use to work fine..
can any one help me whats the prob is?
in terminal it shows like this..
sukeerthi@sukeerthi-desktop:~$ ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
sukeerthi@sukeerthi-desktop:~$
$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0]
puts Time.now.to_date
so where should i make change so that it should work..
in most of the functions i have written

Ruby is not Rails!

The problem is that Time#to_date is an extension which Rails makes to
Ruby.

Not so.

$ qri to_date
------------------------------------------------------ Multiple
choices:

Time#to_date, XSD::XSDDateTimeImpl#to_date

T.
 
J

James Gray

7stud -- wrote:
Sukeerthi Adiga wrote:
Loading development environment.
Time.now.to_date
Time.now.to_date
NoMethodError: private method `to_date' called for Mon Feb 25
12:04:10
+0530 2008:Time
from (irb):1
earlier it use to work fine..
can any one help me whats the prob is?
in terminal it shows like this..
sukeerthi@sukeerthi-desktop:~$ ruby -v
ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
sukeerthi@sukeerthi-desktop:~$
$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0]
puts Time.now.to_date
so where should i make change so that it should work..
in most of the functions i have written

Ruby is not Rails!

The problem is that Time#to_date is an extension which Rails makes to
Ruby.

Not so.

$ qri to_date
------------------------------------------------------ Multiple
choices:

Time#to_date, XSD::XSDDateTimeImpl#to_date

$ qri to_date
------------------------------------------------------ Multiple choices:

ActiveSupport::CoreExtensions::Date::Conversions#to_date,
ActiveSupport::CoreExtensions::String::Conversions#to_date,
ActiveSupport::CoreExtensions::Time::Conversions#to_date,
Time#to_date, XSD::XSDDateTimeImpl#to_date

James Edward Gray II
 
R

Rick DeNatale

Not so.

$ qri to_date
------------------------------------------------------ Multiple
choices:

Time#to_date, XSD::XSDDateTimeImpl#to_date

I'm pretty sure that qri is reporting the method because you have a
gem which defines it. Fastri/qri doesn't restrict itself to the
standard library.
 
P

P. mark Anderson

Here's a simple implementation that fixed my Mephisto installations.

class Time
def to_date
Date.parse(self.to_formatted_s:)db))
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top