ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
rails 4.2
rake, version 10.4.2
I am taking over a project from another developer. I was able to checkout the code from Github and I was able to run "bundle install". But then I do:
bundle exec rake db:setup
rake aborted!
NameError: uninitialized constant Timezone::Configure
This seems to reference something in:
config/application.rb
That file looks like:
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Invtr
class Application < Rails::Application
Timezone::Configure.begin do |c|
c.username = 'AIzaSyAtf'
c.google_api_key = 'AIzaSyAtf'
end
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
end
end
I have been told that this was working for the previous developer, so I have to assume the problem is with something with my setup. But what else do I need to do? Why is the correct gem not being loaded?
The previous developer had put this line in the Gemfile:
gem 'timezone'
And I see:
vendor/cache/ruby/2.3.0/gems/timezone-1.1.1
So the gem is there.
But somehow it is not being loaded in application.rb.
My Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bcrypt', '~> 3.1.7'
gem 'oauth2'
gem 'faraday'
gem 'signet'
gem 'unicorn'
gem 'icalendar'
gem 'quiet_assets', '~> 1.1'
gem 'mongoid', '~> 5.0.0'
gem 'bson_ext'
gem 'devise'
gem 'pry-rails'
gem 'capybara'
gem 'selenium-webdriver'
gem 'simple_form'
gem 'foundation-rails'
gem 'dotenv-rails', :groups => [:development, :test]
gem "mongoid-paperclip", :require => "mongoid_paperclip"
gem 'aws-sdk', '~> 1.3.4'
# CircleCI test metadata formatters
gem 'rspec_junit_formatter', '0.2.2'
gem 'rails_12factor', group: :production
gem 'geocoder'
gem 'timezone'
gem "httpclient"
group :development do
# gem "letter_opener"
end
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'database_cleaner'
gem 'faker'
end
group :test do
gem 'shoulda-matchers'
end
It depends on the version of the timezone
gem you are using. Since version 1.0.0
, you have to make these changes:
in config/application.rb
file instead of using:
Timezone::Configure.begin
for configuration with Geonames you should use:
Timezone::Lookup.config(:geonames)
and for google:
Timezone::Lookup.config(:google)
Also update your Gemfile:
change gem 'timezone'
to gem 'timezone', '~> 1.0'
So your code would look like:
Timezone::Lookup.config(:geonames) do |c|
c.username = 'AIzaSyAtf'
end
or
Timezone::Lookup.config(:google) do |c|
c.api_key = 'AIzaSyAtf'
end
向文件添加require "timezone"
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.