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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ezra Zygmuntowicz
2007-Feb-25 23:53 UTC
Re: how to include activesupport in a ruby script???
On Feb 25, 2007, at 3:35 PM, rph wrote:> > 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! >At the top of your script do this: require ''rubygems'' require ''active_support'' Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 25, 2007, at 6:53 PM, Ezra Zygmuntowicz wrote:> > > On Feb 25, 2007, at 3:35 PM, rph wrote: > >> >> 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! >> > > At the top of your script do this: > > require ''rubygems'' > require ''active_support'' > > Cheers- > > -- Ezra Zygmuntowicz > -- Lead Rails Evangelist > -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org > -- Engine Yard, 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 Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
Hi -- On 2/25/07, rph <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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!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) --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Please can anyone explain why this works in rails but not in irb ?>> require ''active_support''=> true>> Time.now.beginning_of_dayNoMethodError: 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 Zygmuntowicz > -- Lead Rails Evangelist > -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273)-- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 >-- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.