# NoMethodError: private method \`to\_date'

**URL:** <https://rubytalk.org/t/nomethoderror-private-method-to-date/44736>\
**Category:** ruby-talk\
**Created:** [25 February 2008 06:38 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736 "2008-02-25T06:38:30Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sukeerthi\_Adiga](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Sukeerthi\_Adiga](https://rubytalk.org/u/Sukeerthi_Adiga)\
**Post date:** [25 February 2008 06:38 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/1 "2008-02-25T06:38:30Z")

</div>

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  
&nbsp;&nbsp;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:~$

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![7stud](https://avatars.discourse-cdn.com/v4/letter/7/57b2e6/32.png) [@7stud](https://rubytalk.org/u/7stud)\
**Post date:** [25 February 2008 07:03 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/2 "2008-02-25T07:03:46Z")

</div>

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  
> &nbsp;&nbsp;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.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Shiva\_Kumaran](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Shiva\_Kumaran](https://rubytalk.org/u/Shiva_Kumaran)\
**Post date:** [25 February 2008 07:11 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/3 "2008-02-25T07:11:26Z")

</div>

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

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  
> > &nbsp;&nbsp;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:~$
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![P\_mark\_Anderson](https://avatars.discourse-cdn.com/v4/letter/p/58f4c7/32.png) [@P\_mark\_Anderson](https://rubytalk.org/u/P_mark_Anderson)\
**Post date:** [24 July 2008 19:45 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/4 "2008-07-24T19:45:43Z")

</div>

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

class Time  
&nbsp;&nbsp;def to\_date  
&nbsp;&nbsp;&nbsp;&nbsp;Date.parse(self.to\_formatted\_s(:db))  
&nbsp;&nbsp;end  
end

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Sukeerthi\_Adiga](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Sukeerthi\_Adiga](https://rubytalk.org/u/Sukeerthi_Adiga)\
**Post date:** [25 February 2008 07:16 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/5 "2008-02-25T07:16:49Z")

</div>

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  
> > &nbsp;&nbsp;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

> **···**
>
> > --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.
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Sukeerthi\_Adiga](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Sukeerthi\_Adiga](https://rubytalk.org/u/Sukeerthi_Adiga)\
**Post date:** [25 February 2008 07:18 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/6 "2008-02-25T07:18:28Z")

</div>

Shiva Kumaran wrote:

> just try in console mode :/ruby script/console  
> it will work
> 
> 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  
> > &nbsp;&nbsp;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 Test

> > time.now.to\_date

NameError: undefined local variable or method `time' for  
#\<Object:0x2b536c4b8350\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1

> > Time.now.to\_date

NoMethodError: private method `to\_date' called for Mon Feb 25 12:45:18  
+0530 2008:Time  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):2

> **···**
>
> > >
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Deepa\_Shirur](https://avatars.discourse-cdn.com/v4/letter/d/db5fbb/32.png) [@Deepa\_Shirur](https://rubytalk.org/u/Deepa_Shirur)\
**Post date:** [25 February 2008 07:46 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/7 "2008-02-25T07:46:43Z")

</div>

Sukeerthi Adiga wrote:

> Shiva Kumaran wrote:
> 
> > just try in console mode :/ruby script/console  
> > it will work
> > 
> > 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  
> > > &nbsp;&nbsp;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 Test
> 
> > > time.now.to\_date
> 
> NameError: undefined local variable or method `time' for  
> #\<Object:0x2b536c4b8350\>  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):1
> 
> > > Time.now.to\_date
> 
> NoMethodError: private method `to\_date' called for Mon Feb 25 12:45:18  
> +0530 2008:Time  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.

> > Time.now

=\> Mon Feb 25 13:03:46 +0530 2008

> > a = Time.now

=\> Mon Feb 25 13:04:07 +0530 2008

> > a.to\_date

=\> #\<Date: 4909043/2,0,2299161\>

> > Time.now.to\_date

=\> #\<Date: 4909043/2,0,2299161\>  
:0)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale1](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@Rick\_DeNatale1](https://rubytalk.org/u/Rick_DeNatale1)\
**Post date:** [25 February 2008 13:36 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/8 "2008-02-25T13:36:03Z")

</div>

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:

&nbsp;&nbsp;&nbsp;&nbsp;require 'rubygems'  
&nbsp;&nbsp;&nbsp;&nbsp;require 'activesupport'

> **···**
>
> On 2/25/08, Sukeerthi Adiga \<sukeerthiadiga@gmail.com\> wrote:
> 
> > 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
> 
> --  
> Rick DeNatale
> 
> My blog on Ruby  
> [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![Sukeerthi\_Adiga](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Sukeerthi\_Adiga](https://rubytalk.org/u/Sukeerthi_Adiga)\
**Post date:** [25 February 2008 08:49 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/9 "2008-02-25T08:49:06Z")

</div>

> 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.
> 
> > > Time.now
> 
> =\> Mon Feb 25 13:03:46 +0530 2008
> 
> > > a = Time.now
> 
> =\> Mon Feb 25 13:04:07 +0530 2008
> 
> > > a.to\_date
> 
> =\> #\<Date: 4909043/2,0,2299161\>
> 
> > > Time.now.to\_date
> 
> =\> #\<Date: 4909043/2,0,2299161\>  
> :0)

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

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![7rans](https://avatars.discourse-cdn.com/v4/letter/7/a8b319/32.png) [@7rans](https://rubytalk.org/u/7rans)\
**Post date:** [25 February 2008 19:08 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/10 "2008-02-25T19:08:05Z")

</div>

Not so.

$ qri to\_date  
------------------------------------------------------ Multiple  
choices:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time#to\_date, XSD::XSDDateTimeImpl#to\_date

T.

> **···**
>
> On Feb 25, 8:36 am, "Rick DeNatale" \<rick.denat...@gmail.com\> wrote:
> 
> > On 2/25/08, Sukeerthi Adiga \<sukeerthiad...@gmail.com\> wrote:
> > 
> > \> 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.

---

<div class="post-metadata">

**Author:** ![James\_Edward\_Gray\_II](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@James\_Edward\_Gray\_II](https://rubytalk.org/u/James_Edward_Gray_II)\
**Post date:** [25 February 2008 19:33 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/11 "2008-02-25T19:33:50Z")

</div>

$ qri to\_date  
------------------------------------------------------ Multiple choices:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ActiveSupport::CoreExtensions:📅:Conversions#to\_date,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ActiveSupport::CoreExtensions::String::Conversions#to\_date,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ActiveSupport::CoreExtensions::Time::Conversions#to\_date,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time#to\_date, XSD::XSDDateTimeImpl#to\_date

James Edward Gray II

> **···**
>
> On Feb 25, 2008, at 1:08 PM, Trans wrote:
> 
> > On Feb 25, 8:36 am, "Rick DeNatale" \<rick.denat...@gmail.com\> wrote:
> > 
> > > On 2/25/08, Sukeerthi Adiga \<sukeerthiad...@gmail.com\> wrote:
> > > 
> > > > 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:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;Time#to\_date, XSD::XSDDateTimeImpl#to\_date

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale1](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@Rick\_DeNatale1](https://rubytalk.org/u/Rick_DeNatale1)\
**Post date:** [25 February 2008 20:25 UTC](https://rubytalk.org/t/nomethoderror-private-method-to-date/44736/12 "2008-02-25T20:25:33Z")

</div>

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.

> **···**
>
> On 2/25/08, Trans \<transfire@gmail.com\> wrote:
> 
> > On Feb 25, 8:36 am, "Rick DeNatale" \<rick.denat...@gmail.com\> wrote:
> > 
> > \> The problem is that Time#to\_date is an extension which Rails makes to  
> > \> Ruby.
> > 
> > Not so.
> > 
> > $ qri to\_date  
> > ------------------------------------------------------ Multiple  
> > choices:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time#to\_date, XSD::XSDDateTimeImpl#to\_date
> 
> --  
> Rick DeNatale
> 
> My blog on Ruby  
> [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)
