views:

122

answers:

1

The following code

class Schedule < ActiveRecord::Base     
  def self.get  
     today = TZInfo::Timezone.get('America/New_York').utc_to_local(Time.now.utc).to_date
  end    
end

produces the following error:

uninitialized constant Schedule::TZInfo

but only when I'm not running it from script/console. Thoughts?

(Also, is there a better way to get the current date in a given time zone?)

+2  A: 

Have you tried adding

require 'tzinfo'
Reuben Mallaby
This works, but I already added a `config.gem` line in `environment.rb` -- shouldn't that be enough?
Horace Loeb
I believe that just makes sure that the gem is installed - it doesn't necessarily include it 8(
Reuben Mallaby
But see http://stackoverflow.com/questions/1246671
Horace Loeb