Rails 4.1 secrets.yml错误

时间:2014-05-05 05:36:59

标签: ruby-on-rails ruby-on-rails-4 yaml ruby-on-rails-4.1

刚刚升级到Rails 4.1并使用secrets.yml

这就是它的样子:

development:
    secret_key_base: akshdakjshdgakjhsdgakjdhgaskjdhgaskjdhgska

test:
    secret_key_base: somelegitlongasskeygeneratedbyrakesecrethere    
production:
    secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

当我重新启动服务器并访问任何页面时,在浏览器中出现“内部服务器错误”。

在我的日志文件中,我看到了:

$ rails s
=> Booting Thin
=> Rails 4.1.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
Unexpected error while processing request: (<unknown>): found character that cannot start any token while scanning for the next token at line 14 column 1
    /.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:205:in `parse'
    /.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
    /.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:153:in `parse'
    /.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:129:in `load'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/safe_yaml-1.0.3/lib/safe_yaml.rb:15:in `load_with_options'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/application.rb:313:in `secrets'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/application.rb:439:in `validate_secret_key_config!'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/application.rb:195:in `env_config'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/engine.rb:510:in `call'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/application.rb:144:in `call'
    /.rvm/gems/ruby-2.0.0-p353@global/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:86:in `block in pre_process'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:84:in `catch'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:84:in `pre_process'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:53:in `process'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:39:in `receive_data'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
    /.rvm/gems/ruby-2.0.0-p353@global/gems/rack-1.5.2/lib/rack/handler/thin.rb:16:in `run'
    /.rvm/gems/ruby-2.0.0-p353@global/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/server.rb:69:in `start'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:81:in `block in server'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `tap'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `server'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
    bin/rails:4:in `require'
    bin/rails:4:in `<main>'

Unexpected error while processing request: (<unknown>): found character that cannot start any token while scanning for the next token at line 14 column 1
    /.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:205:in `parse'
    /.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
    /.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:153:in `parse'
    /.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:129:in `load'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/safe_yaml-1.0.3/lib/safe_yaml.rb:15:in `load_with_options'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/application.rb:313:in `secrets'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/application.rb:439:in `validate_secret_key_config!'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/application.rb:195:in `env_config'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/engine.rb:510:in `call'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/application.rb:144:in `call'
    /.rvm/gems/ruby-2.0.0-p353@global/gems/rack-1.5.2/lib/rack/content_length.rb:14:in `call'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:86:in `block in pre_process'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:84:in `catch'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:84:in `pre_process'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:53:in `process'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/connection.rb:39:in `receive_data'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
    /.rvm/gems/ruby-2.0.0-p353@global/gems/rack-1.5.2/lib/rack/handler/thin.rb:16:in `run'
    /.rvm/gems/ruby-2.0.0-p353@global/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/server.rb:69:in `start'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:81:in `block in server'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `tap'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in `server'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    /.rvm/gems/ruby-2.0.0-p353@my_project/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
    bin/rails:4:in `require'
    bin/rails:4:in `<main>'

有关可能导致此问题的任何想法?

我尝试了secrets.yml文件的多次迭代,甚至将secret_key_base括在'somelongasskeyhere'这样的单引号中,但这不起作用。

更新1

所以看起来这个问题可能与YAML的风格有关。我认为它与间距和放大器有关。我投入的标签,但我似乎无法完美。现在我在该行的不同位置收到另一个错误。

重新做一些空格只使用空格键4次,而选项卡 - 设置为4个空格,我现在得到一个不同的错误:

Unexpected error while processing request: (<unknown>): found a tab character that violate intendation while scanning a plain scalar at line 13 column 3

参考此行:

development:
  secret_key_base:'86bc42f97803818b48ff88ef15d9d4df6b6b4e4e723c119967a29751de33b5687af3a57542b4a8364cb3d6b51a872ad1188b9de6f0faab578272451aa798956c'

更新2

这绝对与我的间距有关,因为一旦我将这个文件 - https://github.com/RailsApps/rails-devise/blob/master/config/secrets.yml - 复制并粘贴到我的文件中并且刚刚用我的文件替换了key_base,一切都运行正常。

0 个答案:

没有答案