[Heroku] Ruby on Rails 4 + Mongoid + MongoHQ で「500 Internal Server Error」

Tadashi Shigeoka ·  Wed, February 12, 2014

Ruby on Rails 4 + Mongoid + MongoHQ on Heroku という環境で、1stデプロイしたら初っ端から「500 Internal Server Error」に遭遇しました。

エラーログ

 app/web.1:  I, [2014-02-11T01:13:25.785412 #2]  INFO -- : Started GET "/" for 223.132.104.209 at 2014-02-11 01:13:25 +0000 
 app/web.1:  I, [2014-02-11T01:13:25.790612 #2]  INFO -- : Processing by VideosController#index as HTML 
 app/web.1:  I, [2014-02-11T01:13:25.817544 #2]  INFO -- :   Rendered videos/index.html.haml within layouts/application (3.9ms) 
 app/web.1:  I, [2014-02-11T01:13:25.817786 #2]  INFO -- : Completed 500 Internal Server Error in 27ms 
 app/web.1:  F, [2014-02-11T01:13:25.819195 #2] FATAL -- :  
 app/web.1:  ActionView::Template::Error (:consistency is an unknown option. Valid options  :max_retries, :pool_size, :retry_interval, :refresh_interval, :down_interval, :ssl, :timeout, :instrumenter, :auto_discover.): 
 app/web.1:       9:     %th 
 app/web.1:      10:     %th 
 app/web.1:      11:  
 app/web.1:      12:   - @videos.each do |video| 
 app/web.1:      13:     %tr 
 app/web.1:      14:       %td= video.name 
 app/web.1:      15:       %td= video.url 
 app/web.1:    app/views/videos/index.html.haml:12:in `_app_views_videos_index_html_haml___1990342454341184297_70073653532820' 

どうやら、conf/mongoid.yml の書き方が良くなかったみたいです。

MongoHQ 向けの動かない conf/mongoid.yml

production:
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URL'] %>
      options:
        consistency: :strong
        max_retries: 1
        retry_interval: 0

↓ 修正

MongoHQ 向けの正常動作する conf/mongoid.yml

production:
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URL'] %>

options の何がダメだったのか詳しく追ってないので、時間を見付けて最適なオプションを調べたいです。


参考情報

500 Internal Server Error using MongoLab + Rails 4 + Mongoid on Heroku - Stack Overflow