Please, help to solve the problem

46 views
Skip to first unread message

koulikoff

unread,
Aug 5, 2012, 11:27:50 AM8/5/12
to rubyonra...@googlegroups.com
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$ irb
1.9.3p0 :001 > require 'rubygems'
 => false
1.9.3p0 :002 > require 'active_support/core_ext/date/calculations.rb'
 => true
1.9.3p0 :003 > require 'active_support/core_ext/integer/time.rb'
 => true
1.9.3p0 :004 > require 'active_support/core_ext/numeric/time.rb'
 => true
1.9.3p0 :005 > 0.months.since Date.current
ArgumentError: expected a time or date, got #<Date: 2012-08-05 ((2456145j,0s,0n),+0s,2299161j)>
        from /home/d/.rvm/gems/ruby-1.9.3-p0\@t/gems/activesupport-3.2.7/lib/active_support/basic_object.rb:11:in `raise'
        from /home/d/.rvm/gems/ruby-1.9.3-p0\@t/gems/activesupport-3.2.7/lib/active_support/duration.rb:99:in `block in sum'
        from /home/d/.rvm/gems/ruby-1.9.3-p0\@t/gems/activesupport-3.2.7/lib/active_support/duration.rb:91:in `each'
        from /home/d/.rvm/gems/ruby-1.9.3-p0\@t/gems/activesupport-3.2.7/lib/active_support/duration.rb:91:in `inject'
        from /home/d/.rvm/gems/ruby-1.9.3-p0\@t/gems/activesupport-3.2.7/lib/active_support/duration.rb:91:in `sum'
        from /home/d/.rvm/gems/ruby-1.9.3-p0\@t/gems/activesupport-3.2.7/lib/active_support/duration.rb:63:in `since'
        from (irb):5
        from /home/d/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'

With 1.8.7:
ArgumentError: expected a time or date, got #<Date: 4912289/2,0,2299161>
        from /var/lib/gems/1.8/gems/activesupport-3.2.7/lib/active_support/duration.rb:99:in `sum'
        from (irb):6:in `inject'
        from /var/lib/gems/1.8/gems/activesupport-3.2.7/lib/active_support/duration.rb:91:in `each'
        from /var/lib/gems/1.8/gems/activesupport-3.2.7/lib/active_support/duration.rb:91:in `inject'
        from /var/lib/gems/1.8/gems/activesupport-3.2.7/lib/active_support/duration.rb:91:in `sum'
        from /var/lib/gems/1.8/gems/activesupport-3.2.7/lib/active_support/duration.rb:63:in `since'
        from (irb):6
        from :0

thank you in advance

Robert Walker

unread,
Aug 5, 2012, 12:05:11 PM8/5/12
to rubyonra...@googlegroups.com
Dmitri K. wrote in post #1071361:
> $ ruby -v
> ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
> $ irb
> 1.9.3p0 :001 > require 'rubygems'
> => false
> 1.9.3p0 :002 > require 'active_support/core_ext/date/calculations.rb'
> => true
> 1.9.3p0 :003 > require 'active_support/core_ext/integer/time.rb'
> => true
> 1.9.3p0 :004 > require 'active_support/core_ext/numeric/time.rb'
> => true
> 1.9.3p0 :005 > 0.months.since Date.current
> ArgumentError: expected a time or date, got #<Date: 2012-08-05
> ((2456145j,0s,0n),+0s,2299161j)>

Since this statement works fine if all of Rails is loaded then you must
still be missing some required files.


$ rails c
Loading development environment (Rails 3.2.7)
irb(main):001:0> Date.current
=> Sun, 05 Aug 2012
irb(main):002:0> 0.months.since Date.current
=> Sun, 05 Aug 2012

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

koulikoff

unread,
Aug 5, 2012, 1:06:15 PM8/5/12
to rubyonra...@googlegroups.com


On Sunday, August 5, 2012 7:05:11 PM UTC+3, Ruby-Forum.com User wrote:

Since this statement works fine if all of Rails is loaded then you must
still be missing some required files.


$ rails c
Loading development environment (Rails 3.2.7)
irb(main):001:0> Date.current
=> Sun, 05 Aug 2012
irb(main):002:0> 0.months.since Date.current
=> Sun, 05 Aug 2012

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

Yes, in rails it works, I know. But I do not need to load the whole framework for just the data manipulation. What file is missing to load?
 

soldier

unread,
Aug 5, 2012, 10:42:49 PM8/5/12
to rubyonra...@googlegroups.com
require "active_support/core_ext/date/acts_like"
miss this for acts_like_date? function.

i think you can easy to this.

require 'active_support/core_ext'
puts 0.months.since Date.current
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/SC86H6UDa7oJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

koulikoff

unread,
Aug 6, 2012, 3:14:11 PM8/6/12
to rubyonra...@googlegroups.com


On Monday, August 6, 2012 5:42:49 AM UTC+3, hhuai wrote:
require "active_support/core_ext/date/acts_like"
miss this for acts_like_date? function.

Yes, thank you very much
Reply all
Reply to author
Forward
0 new messages