uninitialized constant Moped::BSON in rails 4 app on heroku

后端 未结 3 1921
时光取名叫无心
时光取名叫无心 2021-02-09 07:52

I just updated from rails 3 to rails 4. Everything works locally, but deployed on heroku, I get the following error:

ActionView::Template::Error (uninitialized c         


        
相关标签:
3条回答
  • 2021-02-09 08:21

    The following worked for me:

    add to Gemfile:

    gem "bson"
    gem "moped", github: "mongoid/moped"
    

    bundle install

    add to application.rb:

    require "bson"
    require "moped"
    Moped::BSON = BSON
    

    Answer from: https://github.com/mongoid/mongoid/issues/3455

    0 讨论(0)
  • 2021-02-09 08:30

    See this comment from Moped's author as of Moped 2.0.0 (which is the version , as of this writing, used as the driver in mongoid 4.0.0):

    Moped's BSON implementation has been removed in favor of the 10gen bson gem 2.0 and higher. All Moped::BSON references should be changed to just BSON.
    

    https://github.com/mongoid/moped/blob/master/CHANGELOG.md

    0 讨论(0)
  • 2021-02-09 08:37

    This error can also be caused by having references to Moped::BSON in serialized cookies/session. Deleting cookies fixes it then.

    0 讨论(0)
提交回复
热议问题