我的目标是将所有凭据存储到config/secret.yml
并将其从git中删除。
下面的配置在Mac OS X上按预期工作,但在Windows 7上会引发错误。
使用config / database.yml:
default: &default
adapter: postgresql
encoding: unicode
username: <%= Rails.application.secrets.database_username %>
password: <%= Rails.application.secrets.database_password %>
development:
<<: *default
database: project1_development
test:
<<: *default
database: project1_test
production:
<<: *default
database: project1_production
和config / secrets.yml:
development:
secret_key_base: d48527bc8072d6d84ebd037c2324f474af315459b2c7912f6e1e3abfb616e0f92cdca194845d4235b287f032345312d3aec870d391b603dd8d1a888185f7c642
database_username: postgres
database_password: test-test
test:
secret_key_base: d48527bc8072d6d84ebd037c2324f474af315459b2c7912f6e1e3abfb616e0f92cdca194845d4235b287f032345312d3aec870d391b603dd8d1a888185f7c642
database_username: postgres
database_password: test-test
rails server
引发错误:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_record/connect
ion_adapters/connection_specification.rb:171:in `spec': database configuration d
oes not specify adapter (ActiveRecord::AdapterNotSpecified)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_r
ecord/connection_handling.rb:50:in `establish_connection'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_r
ecord/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/lazy_load_hooks.rb:38:in `instance_eval'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/lazy_load_hooks.rb:38:in `execute_hook'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/lazy_load_hooks.rb:44:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/lazy_load_hooks.rb:44:in `run_load_hooks'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_r
ecord/base.rb:316:in `<module:ActiveRecord>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-4.2.0/lib/active_r
ecord/base.rb:26:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/devise-3.4.1/lib/devise/orm/act
ive_record.rb:3:in `<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:274:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:274:in `block in require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:240:in `load_dependency'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:274:in `require'
from C:/Users/biske/mladizubinpotok/config/initializers/devise.rb:22:in
`block in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/devise-3.4.1/lib/devise.rb:293:
in `setup'
from C:/Users/biske/mladizubinpotok/config/initializers/devise.rb:3:in `
<top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:268:in `load'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:268:in `block in load'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:240:in `load_dependency'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:268:in `load'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/engine
.rb:652:in `block in load_config_initializer'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/notifications.rb:166:in `instrument'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/engine
.rb:651:in `load_config_initializer'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/engine
.rb:616:in `block (2 levels) in <class:Engine>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/engine
.rb:615:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/engine
.rb:615:in `block in <class:Engine>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/initia
lizable.rb:30:in `instance_exec'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/initia
lizable.rb:30:in `run'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/initia
lizable.rb:55:in `block in run_initializers'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:150:in `block in tsort_each'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:183:in `block (2 levels) in each
_strongly_connected_component'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:210:in `block (2 levels) in each
_strongly_connected_component_from'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:219:in `each_strongly_connected_
component_from'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:209:in `block in each_strongly_c
onnected_component_from'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/initia
lizable.rb:44:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/initia
lizable.rb:44:in `tsort_each_child'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:203:in `each_strongly_connected_
component_from'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:182:in `block in each_strongly_c
onnected_component'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:180:in `each'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:180:in `each_strongly_connected_
component'
from C:/Ruby193/lib/ruby/1.9.1/tsort.rb:148:in `tsort_each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/initia
lizable.rb:54:in `run_initializers'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/applic
ation.rb:352:in `initialize!'
from C:/Users/biske/mladizubinpotok/config/environment.rb:5:in `<top (re
quired)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:274:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:274:in `block in require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:240:in `load_dependency'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.2.0/lib/active_
support/dependencies.rb:274:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/applic
ation.rb:328:in `require_environment!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/comman
ds/commands_tasks.rb:142:in `require_application_and_environment!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/comman
ds/commands_tasks.rb:67:in `console'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/comman
ds/commands_tasks.rb:39:in `run_command!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.2.0/lib/rails/comman
ds.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Ruby版本:
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
Rails版本:
Rails 4.2.0
对此有何帮助?