我是ruby的新手。今天我从源头安装了工头。
当我运行命令RAILS_ENV=production bundle exec rake db:seed assets:precompile locale:pack
时,它会生成以下错误消息。
我不认为代码有问题,因为我得到了代码
来自git with command git clone https://github.com/theforeman/foreman.git -b 1.7-stable
收到错误消息后,我执行以下操作:编辑文件ROOTDIR / config / application.rb,添加以下行,但它也会收到相同的错误消息
config.i18n.enforce_available_locales = false
config.i18n.available_locales = ["zh-CN"]
#config.i18n.default_locales = :'zh-CN'
我的ruby verision是ruby-2.0.0-p451
期待有人能让我走出困境。感谢。
########## error message ############
rake aborted!
I18n::InvalidLocale: :en is not a valid locale
/root/foreman/vendor/ruby/2.0.0/gems/i18n-0.7.0/lib/i18n.rb:284:in `enforce_available_locales!'
/root/foreman/vendor/ruby/2.0.0/gems/i18n-0.7.0/lib/i18n.rb:151:in `translate'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/naming.rb:57:in `human'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/errors.rb:346:in `generate_message'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/errors.rb:359:in `normalize_message'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/errors.rb:234:in `add'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations/inclusion.rb:19:in `validate_each'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validator.rb:153:in `block in validate'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validator.rb:150:in `each'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validator.rb:150:in `validate'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:310:in `_callback_before_105'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:550:in `_run__2320509037395656532__validate__260782132788772307__callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:405:in `__run_callback'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:385:in `_run_validate_callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:81:in `run_callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations.rb:228:in `run_validations!'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations/callbacks.rb:53:in `block in run_validations!'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:425:in `_run__2320509037395656532__validation__260782132788772307__callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:405:in `__run_callback'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:385:in `_run_validation_callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:81:in `run_callbacks'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations/callbacks.rb:53:in `run_validations!'
/root/foreman/vendor/ruby/2.0.0/gems/activemodel-3.2.21/lib/active_model/validations.rb:195:in `valid?'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/validations.rb:69:in `valid?'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/validations.rb:77:in `perform_validations'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/validations.rb:50:in `save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/attribute_methods/dirty.rb:22:in `save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:259:in `block (2 levels) in save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:208:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:259:in `block in save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:258:in `save'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/persistence.rb:217:in `block in update_attributes'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:208:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/persistence.rb:215:in `update_attributes'
/root/foreman/app/models/setting.rb:177:in `block in create_existing'
/root/foreman/app/models/setting.rb:184:in `bypass_readonly'
/root/foreman/app/models/setting.rb:174:in `create_existing'
/root/foreman/app/models/setting.rb:167:in `create!'
/root/foreman/app/models/setting/general.rb:29:in `block (2 levels) in load_defaults'
/root/foreman/app/models/setting/general.rb:29:in `each'
/root/foreman/app/models/setting/general.rb:29:in `block in load_defaults'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/transactions.rb:208:in `transaction'
/root/foreman/app/models/setting/general.rb:13:in `load_defaults'
/root/foreman/config/initializers/foreman.rb:20:in `each'
/root/foreman/config/initializers/foreman.rb:20:in `<top (required)>'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `load'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `block in load'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:245:in `load'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/engine.rb:592:in `each'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/engine.rb:592:in `block in <class:Engine>'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `instance_exec'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `run'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:55:in `block in run_initializers'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `each'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `run_initializers'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:136:in `initialize!'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/railtie/configurable.rb:30:in `method_missing'
/root/foreman/config/environment.rb:5:in `<top (required)>'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `block in require'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
/root/foreman/vendor/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:103:in `require_environment!'
/root/foreman/vendor/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
/root/foreman/vendor/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/railties/databases.rake:346:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:abort_if_pending_migrations => environment
答案 0 :(得分:0)
更改
config.i18n.available_locales = [“zh-CN”]
到
config.i18n.available_locales = [“zh-CN”,:en]