麻烦安装Devise宝石 [英] Trouble installing Devise gem

查看:165
本文介绍了麻烦安装Devise宝石的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚尝试安装设备,有一些麻烦。从以前的经验我知道,当我安装它,我需要做一些手动步骤。那么这个时候那里没有手动的步骤,但我还是做了他们,因为我知道他们必须完成。所以一切都正常,但是我运行 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没有设置。 
请将以下内容添加到您的Devise初始化程序中:(RuntimeError)

config.secret_key ='1ef096dceb32ce5af3b11a7ef99c00ab59b7ad90ed5dbacabe5e8cb8613e437799333b96e2045997d701a1ed1b1fde537b98f6ef1c64d247516b85c9410ad147'

请确保在安装Devise或设置后重新启动应用程序钥匙。
来自/Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/lib/devise/rails/routes.rb:203:in`devise_for'
/来自/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:在`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:在`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 (必需)>'
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:在`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`load in load_paths'
从/Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:ineach
from /用户/ henrywyatt / .rvm / gems / ruby​​-2.0.0-p353 / gems / railties-4.0.2 / lib / rails / application / routes_reloader.rb:40:在`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:在`block in updater'
来自/Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in来自/ Users / henrywyatt的`call'
/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in$
来自/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:在`execute_if_updated'
from /Users/henrywyatt/.rvm/gems/ruby-2.0.0 -p353 / gems / railties-4.0.2 / lib / rails / application / finisher.rb:69:在`block in< module:Finisher>'
from /Users/henrywyatt/.rvm/gems/ruby -2.0.0-p353 / gems / railties-4.0.2 / lib / rails / initializable.rb:30:在`instance_exec'
from /Users/henrywyatt/.rvm/gems/ruby-2.0.0- p353 / gems / railties-4.0.2 / lib / rails / initializable.rb:30:在`run'
from /Users/henrywyatt/.rvm/gems/ruby-2.0 .0-p353 / gems / railties-4.0.2 / lib / rails / initializable.rb:55:在`block in run_initializers'
from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0- p353 / lib / ruby​​ / 2.0.0 / tsort.rb:150:在`block in tsort_each'
from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0 .0 / tsort.rb:183:在每个_strongly_connected_component中的`block(2 levels)'
from /Users/henrywyatt/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/ tsort.rb:219:在`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 /用户/ henrywyatt / .rvm / rubies / ruby​​-2.0.0-p353 / lib / ruby​​ / 2.0.0 / tsort.rb:180:在`each_strongly_connected_component'
from /Users/henrywyatt/.rvm/rubies/ ruby-2.0.0-p353 / lib / ruby​​ / 2.0.0 / tsort.rb:148:在`tsort_each'
from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p 353 / gems / railties-4.0.2 / lib / rails / initializable.rb:54:在`run_initializers'
from /Users/henrywyatt/.rvm/gems/ruby-2.0.0-p353/gems/railties -4.0.2 / lib / rails / application.rb:215:在`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:在`load_dependency'
from /Users/henrywyatt/.rvm/ gems / ruby​​-2.0.0-p353 / gems / activesupport-4.0.2 / lib / active_support / dependencies.rb:229:在`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)>'
从bin / rails:4:在`require'
从bin / rails:4:在`< main>'


解决方案

如果你在生产中不要把它放在任何配置文件中,而不是把它当作环境变量
rails 4有一个secret.yml文件有一行

  secret_key_base:<%= ENV [SECRET_KEY_BASE]%> 

您只需要设置ENV [SECRET_KEY_BASE]



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


I just attempted installing devise and had some trouble. From previous experience I know that when I install it I am required to do some manual steps. Well this time there where no manual steps but I still did them because I know they had to be done. So everything is working fine but then I run rails g devise: views this returns

/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>'

解决方案

if you are on production dont put this in any config file rather put it as environment variable rails 4 have one secret.yml file in which there is a line

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

you just need to set ENV["SECRET_KEY_BASE"]

I am not sure but secret key is any string

这篇关于麻烦安装Devise宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆