Rails控制台无法从I18n的错误启动 [英] Rails console fails to start with error from I18n
本文介绍了Rails控制台无法从I18n的错误启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试启动控制台时,我会得到
When I try to start console I get
/home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n/backend/base.rb:158:in `load_file': can not load translations from /var/www/railsapp/config/locales/ru.yml, expected it to return a hash, but does not (I18n::InvalidLocaleData)
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n/backend/base.rb:15:in `block in load_translations'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n/backend/base.rb:15:in `each'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n/backend/base.rb:15:in `load_translations'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n/backend/simple.rb:57:in `init_translations'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n/backend/simple.rb:71:in `lookup'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n/backend/base.rb:26:in `translate'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n.rb:156:in `block in translate'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n.rb:152:in `catch'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/i18n-0.6.1/lib/i18n.rb:152:in `translate'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.1.0/lib/active_record/railtie.rb:102:in `block in <class:Railtie>'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:34:in `call'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.0/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `instance_exec'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/initializable.rb:25:in `run'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/initializable.rb:50:in `block in run_initializers'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `each'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/initializable.rb:49:in `run_initializers'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/application.rb:92:in `initialize!'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /var/www/railsapp/config/environment.rb:6:in `<top (required)>'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/application.rb:78:in `require'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/application.rb:78:in `require_environment!'
from /home/username/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.0/lib/rails/commands.rb:39:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我的应用运行正常,只有控制台无法启动. 可能此问题与从第二个Rails版本升级有关.但是一年来它一直运行良好.
My app works fine, only console doesn't start. May be this problem is related to upgrade from the second rails version. But for a year it has been worked fine.
我的ru.yml:
ru:
activerecord:
attributes:
user:
password: "Пароль"
login: "Имя пользователя"
password_confirmation: "Повтор пороля"
models:
user: "пользователь"
这是一个错误的错误.从ru.yml中删除评论后,一切正常.
It was a fantom error. After delete comments from ru.yml everything worked fine.
推荐答案
您的ru.yml
似乎不正确,您可能需要使用双空格缩进,rails不会将您的翻译视为哈希,请尝试更改yml使用两个空格.
Your ru.yml
doesn't seems right, you probably need a double space indentation, rails doesn't see your translations as a hash, try change your yml to use two spaces.
这篇关于Rails控制台无法从I18n的错误启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文