我有一个简单的rails应用程序,我试图通过Capistrano回复。该应用程序在开发中工作正常但在部署时失败。我将其追溯到资产:预编译步骤,在本地计算机上也失败了。我已经看到了其他类似问题的其他帖子,但没有任何真正指向我的正确方向。
我不够强大,无法确定下一步的位置,所以任何指针都会受到赞赏。
Solara:myapp dan$ rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
NoMethodError: undefined method `tr' for nil:NilClass
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:37:in `initialize'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:270:in `new'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:270:in `resolve_url_connection'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:258:in `resolve_hash_connection'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:215:in `resolve_connection'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:139:in `resolve'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:151:in `block in resolve_all'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:150:in `each'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:150:in `resolve_all'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:69:in `resolve'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/core.rb:46:in `configurations='
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/railtie.rb:117:in `block (2 levels) in <class:Railtie>'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:27:in `each'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.2.4/lib/active_record/railtie.rb:116:in `block in <class:Railtie>'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `call'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
/Users/dan/Rails/myapp/config/environment.rb:5:in `<top (required)>'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.4/lib/rails/application.rb:328:in `require_environment!'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.2.4/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/dan/.rvm/gems/ruby-2.0.0-p247/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:199:in `each'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/dan/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/dan/.rbenv/versions/2.2.0/bin/rake:33:in `<main>'
Tasks: TOP => environment
Solara:wingnut dan$
答案 0 :(得分:5)
您的数据库设置看起来像是一个问题,可能在config/database.yml
以下是抛出错误的代码:
# == Example
#
# url = "postgresql://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000"
# ConnectionUrlResolver.new(url).to_hash
# # => {
# "adapter" => "postgresql",
# "host" => "localhost",
# "port" => 9000,
# "database" => "foo_test",
# "username" => "foo",
# "password" => "bar",
# "pool" => "5",
# "timeout" => "3000"
# }
def initialize(url)
raise "Database URL cannot be empty" if url.blank?
@uri = uri_parser.parse(url)
@adapter = @uri.scheme.tr('-', '_')
因此,由于某种原因,它无法确定您尝试连接的数据库类型(如PostgreSQL)。如果您仍然遇到问题,请发布您database.yml
文件的内容,记住要删除密码。