How to include activesupport in a ruby script?

I have a ruby script (not in a rails app) that pulls in delicious data
from their API, and then I read that data out of a file. I’m having
trouble formatting the date coming back from delicious.

I’d like to use ‘.to_date’ as that works fine from within the rails app,
but I don’t know how to access (or require) the activesupport gem that
would give me access to the ‘conversions.rb’ file that has the ‘to_date’
method.

I’ve tried doing this at the top of my script:

require ‘activesupport/core_ext/date/conversions.rb’

Or whatever it is, but nothing is working. Any thoughts? I’d really
appreciate the help. Thanks!

On Feb 25, 2007, at 3:35 PM, rph wrote:

method.

I’ve tried doing this at the top of my script:

require ‘activesupport/core_ext/date/conversions.rb’

Or whatever it is, but nothing is working. Any thoughts? I’d really
appreciate the help. Thanks!

At the top of your script do this:

require ‘rubygems’
require ‘active_support’

Cheers-

– Ezra Z.
– Lead Rails Evangelist
[email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)

On Feb 25, 2007, at 6:53 PM, Ezra Z. wrote:

I’d like to use ‘.to_date’ as that works fine from within the rails

– Ezra Z.
– Lead Rails Evangelist
[email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)

And if you need to specify a particular version:

require ‘rubygems’
gem ‘activesupport’, ‘>=1.4’
require ‘active_support’

Note that the name of the gem has no ‘_’ (I beat my head on that one
a few weeks ago). The ‘gem’ method sets up the load path for a
version of the gem that meets the requested restriction.

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

Please can anyone explain why this works in rails but not in irb ?

require ‘active_support’
=> true

Time.now.beginning_of_day
NoMethodError: undefined method `beginning_of_day’ for Fri Oct 29
14:05:28 +1300 2010:Time
from (irb):2

Thanks
Ben

At the top of your script do this:

require ‘rubygems’
require ‘active_support’

Cheers-

– Ezra Z.
– Lead Rails Evangelist
[email protected]
– Engine Y., Serious Rails Hosting
– (866) 518-YARD (9273)

Hi –

On 2/25/07, rph [email protected] wrote:

I’ve tried doing this at the top of my script:

require ‘activesupport/core_ext/date/conversions.rb’

Or whatever it is, but nothing is working. Any thoughts? I’d really
appreciate the help. Thanks!

Try this:

require ‘rubygems’
require ‘active_support/core_ext/date/conversions’

(Note that you don’t need, and actually should not use, the .rb
extension in a require, unless you’re giving it a fully qualified path
to a file.)

David


Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
(See what readers are saying! http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)

Solved now,

require ‘active_support/all’
=> true

Time.now.beginning_of_day
=> Mon Nov 01 00:00:00 1300 2010

Ben Williams wrote in post #957932:

Please can anyone explain why this works in rails but not in irb ?

require ‘active_support’
=> true

Time.now.beginning_of_day
NoMethodError: undefined method `beginning_of_day’ for Fri Oct 29
14:05:28 +1300 2010:Time
from (irb):2

Thanks
Ben