我正在尝试在 CentOS 6.2 上安装 RedMine,但是在尝试访问该站点时遇到了困难。使用本指南,我在 中配置了以下内容environment.rb
:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Make sure there's no plugin in vendor/plugin before starting
vendor_plugins_dir = File.join(Rails.root, "vendor", "plugins")
if Dir.glob(File.join(vendor_plugins_dir, "*")).any?
$stderr.puts "Plugins in vendor/plugins (#{vendor_plugins_dir}) are no longer allowed. " +
"Please, put your Redmine plugins in the `plugins` directory at the root of your " +
"Redmine directory (#{File.join(Rails.root, "plugins")})"
exit 1
end
ENV['RAILS_ENV'] ||= 'production'
#RAILS_ENV=production bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate
# Initialize the rails application
RedmineApp::Application.initialize!
不幸的是,我不断遇到以下错误:
undefined method 'db' for main:Object
当我尝试手动运行命令时遇到同样的问题:
[root@nag0 config]# rake db:migrate --trace
(in /var/www/html/redmine-2.2.2)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `db' for main:Object
/var/www/html/redmine-2.2.2/config/environment.rb:16
/usr/lib64/ruby/gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:103:in `require'
/usr/lib64/ruby/gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
/usr/lib64/ruby/gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:297:in `initialize_tasks'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:228:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:166:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:187:in `invoke_prerequisites'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:185:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:165:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:101:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:73:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/usr/lib64/ruby/gems/1.8/gems/rake-10.0.3/bin/rake:33
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Tasks: TOP => db:migrate => environment
我已经database.yml
使用我的 MySQL 数据库登录名/密码配置了该文件。
鉴于我对 Ruby 总体上还不熟悉,我确信我做错了什么,但不幸的是我对 Ruby 的工作原理了解不够,无法进一步排除故障。
我们非常感谢您的任何建议。
答案1
您能否确认您已配置config/database.yml
而不是config/db.yml
?如果没有,则说明您错误地命名了数据库配置文件。
你也误读了指南。在生成会话存储,列出要执行的命令 - 而不是添加environment.rb
。
删除线条
#RAILS_ENV=production bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate
从您的environment.rb
并继续通过执行命令在指南中生成会话存储在命令行上。