3

我是红宝石新手。我只是试图设置设计。我按照https://github.com/plataformatec/devise上的说明进行操作,当我收到rake db:migrate命令时,它告诉我 rake 已中止,并且“没有将 nil 隐式转换为字符串”。这很令人沮丧,因为我正在做指南/视频正在做的事情并且我得到了一个错误。

请参阅下面的错误。

User$ rake db:migrate
rake aborted!
no implicit conversion of nil into String
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:24:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:24:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:24:in `sqlite3_connection'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:53:in `connection'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/migration.rb:863:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:in `up'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/migration.rb:742:in `migrate'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

谢谢你。

4

3 回答 3

2

很可能是由于config/database.yml文件错误。这是一个常规的:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000
于 2013-07-22T19:54:47.357 回答
2

我遇到了同样的问题,这是由以下行引起的config/initializers/devise.rb

config.mailer_sender = 'no-reply@' + Rails.application.secrets.domain_name

Rails.application.secrets.domain_namesecrets.yml未设置中定义的,这对我来说是错误的原因。

于 2015-08-31T02:04:40.680 回答
1

每次我尝试rake install使用宝石时,Rake 都会给我这个信息。它会成功打包 gem,然后尝试运行ruby -S gem install pkg/my_gem.version.gem. 它会失败。

奇怪的是,从命令行运行命令会成功安装相同的 gem。

看到其他人建议应该重新安装所有 gem,我尝试重新安装 rake gem。它似乎已经修复了它。(我还重新安装了 bundler gem,但我不认为这是问题所在)。

于 2016-06-30T18:58:02.717 回答