0

I was trying to add time_zone_select locales as outlined on this guide but have messed up my rails app in the process. When I start the rails server with rails s, I get the following error:

/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated': Rails::Application
::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007f946155b930 @paths=["
/Users/DaniG2k/Documents/Aptana Studio 3 Workspace/MyApp/config/routes.rb"], @route_sets=[#<ActionDispatch::Routing::RouteSet:0x007f9464045150>]> (RuntimeError
)
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /Users/DaniG2k/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
        from /Users/DaniG2k/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
        from /Users/DaniG2k/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
        from /Users/DaniG2k/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
        from /Users/DaniG2k/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
        from /Users/DaniG2k/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
        from /Users/DaniG2k/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /Users/DaniG2k/Documents/Aptana Studio 3 Workspace/MyApp/config/environment.rb:5:in `<top (required)>'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /Users/DaniG2k/Documents/Aptana Studio 3 Workspace/MyApp/config.ru:3:in `block in <main>'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
        from /Users/DaniG2k/Documents/Aptana Studio 3 Workspace/MyApp/config.ru:in `new'
        from /Users/DaniG2k/Documents/Aptana Studio 3 Workspace/MyApp/config.ru:in `<main>'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands/server.rb:48:in `app'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands/server.rb:75:in `start'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:78:in `block in <top (required)>'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
        from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

Basically, I think it boils down to an issue with my locales but I cannot understand what it is. I put a binding.pry in my routes.rb right before the lines

get '' => redirect("/#{I18n.default_locale}")
  scope "/:locale", locale: /#{I18n.available_locales.join("|")}/ do

and I noticed that from there, if I do I18n.available_locales I get:

NoMethodError: undefined method `deep_symbolize_keys' for "国際日付変更線&quot;:String
from /Users/DaniG2k/.rvm/gems/ruby-2.0.0-p247/gems/i18n-0.6.5/lib/i18n/backend/simple.rb:34:in `store_translations'

I tried removing all double quotes in my locale .yml files but that does not seem to have fixed the issue.

This is my current locales structure:

config/
  locales/
    defaults/
      en.yml
      ja.yml
    timezones/
      ja.yml
    devise.en.yml
    en.yml
    ja.yml

And the locales file that seems to be failing is:

ja:
  timezones:
    "International Date Line West": "国際日付変更線&quot;
    "Midway Island": "ミッドウェイ諸島"
    "American Samoa": "米領サモア&quot;
    "Samoa": "サモア&quot;
    "Hawaii": "ハワイ&quot;
    "Alaska": "アラスカ"
    "Pacific Time (US & Canada)": "太平洋標準時 (アメリカ・カナダ)"
    etc...

But there seem to be no odd spaces or anything so it should be working properly. I also have this in my app/models/ directory, not sure if it makes a difference at all for the failure messages:

#app/models/i18n_time_zone.rb
class I18nTimeZone < ActiveSupport::TimeZone
  def to_s
    translated_name = I18n.t(name, :scope => :timezones, :default => name)
    "(GMT#{formatted_offset}) #{translated_name}"
  end
end

Until this is fixed I can't even start my rails console or server...-_- Any ideas how I can resolve this issue?

Thanks in advance!

4

1 回答 1

3

手动重新缩进整个时区 yml 文件似乎已经解决了这个问题。

于 2013-09-08T11:50:51.310 回答