以下に示すように、Mongoidの本番部分にレプリケーションを追加しました。
production:
hosts:
- - <%= ENV['MONGO_URL1'] %>:<%= ENV['MONGO_PORT'] %>
- - <%= ENV['MONGO_URL2'] %>:<%= ENV['MONGO_PORT'] %>
read: :secondary
username: <%= ENV['MONGO_USERNAME'] %>
password: <%= ENV['MONGO_PASSWORD'] %>
database: <%= ENV['MONGO_DATABASE'] %>
max_retries_on_connection_failure: 10
これはHerokuの本番環境で機能しますが、ローカルでは、サーバーがエラーを出し始めて失敗する原因になっています。
ROOT /Users/bashar/rails-projects/my-project /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/syck.rb:135:in ---
load': syntax error on line 13, col 9:
: ' (ArgumentError)from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/syck.rb:135:inload' from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mongoid-2.4.7/lib/mongoid/railtie.rb:83:in
block in'from /Users/bashar/.rvm/rubies /ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in run'frominstance_exec' from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in
/Users/bashar/.rvm/rubies /ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:55:in each'fromblock in run_initializers' from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:in
/Users/bashar/.rvm/rubies /ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:inrun_initializers' from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:96:in
初期化!」/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:inからmethod_missing' from /Users/bashar/rails-projects/my-project/config/environment.rb:5:in
'/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:inrequire' from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in
ブロックから/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223からのrequire': /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223のblock in load_dependency' from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in
new_constants_in'にあります。load_dependency' from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:83からのrequire' :in'fromrequire_environment!' from /Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/commands.rb:39:in
script / rails:6:inrequire' from script/rails:6:in
'〜/ rails-projects / my-project/[マスター]
Rails 3.1.3 Mongo 1.6.2 Mongoid2.4.9MongoDBバージョン2.0.2を使用しています
何か案が?