我有我的development.yml文件的以下开发部分: development: adapter: postgresql host: localhost database: testtb username: app_user password: ENV['APP_USER_POSTGRES_PASSWORD'] <= Troublesome line 当我通过bundle exec rails console打开bundle exec rails console并inputENV['APP_USER_POSTGRES_PASSWORD']我找回了我在本地configuration文件中指定的数据库密码。 但是,当我启动我的导轨服务器时,无法连接到数据库,失败 PGError FATAL: password authentication failed for user "app_user" 这是以前工作,当我有数据库密码实际input纯文本,而不是尝试通过ENV['…']访问它,但由于显而易见的原因,我想保留实际密码完全从这个文件因此不在代码库中),同时仍然能够对database.yml文件进行其他非安全更改。 有没有什么特别的关于我缺less的语法 ,或者是在加载database.yml文件时出于某种原因不可用的环境variables?
我正在运行一个Rails 2.3.5应用程序,并运行脚本/服务器时,我显示以下内容: ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) from ./script/../config/boot.rb:60:in `load_initializer' from ./script/../config/boot.rb:44:in `run' from ./script/../config/boot.rb:17:in `boot!' from ./script/../config/boot.rb:123 from script/server:2:in `require' from script/server:2 如果我在boot.rb(Rails :: GemDependency.add_frozen_gem_path)中注释掉第60行并运行脚本/服务器,我得到这个: => Booting WEBrick => Rails 2.3.5 application starting on http://0.0.0.0:3000 ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) from ./script/../config/../vendor/rails/railties/lib/initializer.rb:298:in `add_gem_load_paths' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:132:in `process' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in […]
我正在使用Rails 2.3.5,如果我给Model.find(1) ,如果1不在数据库中,则返回ActiveRecord错误。 是否应该像Model.find_by_column('..')一样返回nil ?