无法安装Devise gem

时间:2014-01-01 21:34:37

标签: ruby devise gem

我只是尝试安装设备并遇到了一些麻烦。根据以前的经验,我知道当我安装它时,我需要做一些手动步骤。那么这次没有手动步骤,但我仍然这样做,因为我知道他们必须完成。所以一切正常,但我运行rails g devise: views返回

/Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/rails/routes.rb:469:in `raise_no_secret_key': Devise.secret_key was not set. 
Please add the following to your Devise initializer: (RuntimeError)

config.secret_key = '1ef096dceb32ce5af3b11a7ef99c00ab59b7ad90ed5dbacabe5e8cb8613e437799333b96e2045997d701a1ed1b1fde537b98f6ef1c64d247516b85c9410ad147'

Please ensure you restarted your application after installing Devise or setting the key.
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/rails/routes.rb:203:in `devise_for'
  from /Users/henrywyatt/Desktop/pinteresting/config/routes.rb:2:in `block in <top (required)>'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:319:in `draw'
  from /Users/henrywyatt/Desktop/pinteresting/config/routes.rb:1:in `<top (required)>'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `call'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `execute'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
  from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
  from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
  from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
  from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
  from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:180:in `each'
  from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
  from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
  from /Users/henrywyatt/Desktop/pinteresting/config/environment.rb:5:in `<top (required)>'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application.rb:189:in `require_environment!'
  from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:44:in `<top (required)>'
  from bin/rails:4:in `require'
  from bin/rails:4:in `<main>'

3 个答案:

答案 0 :(得分:1)

您需要添加

config.secret_key = '1ef096dceb32ce5af3b11a7ef99c00ab59b7ad90ed5dbacabe5e8cb8613e437799333b96e204599‌​7d701a1ed1b1fde537b98f6ef1c64d247516b85c9410ad147'

到您的设备文件(config / initializers / devise initializer.rb)。

答案 1 :(得分:1)

如果您正在制作,请不要将其放在任何配置文件中,而是将其作为环境变量 rails 4有一个secret.yml文件,其中有一行

secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

你只需要设置ENV [&#34; SECRET_KEY_BASE&#34;]

我不确定,但密钥是任何字符串

答案 2 :(得分:0)

我也有同样的问题 但在重新启动我的rails服务器后解决了它

相关问题