Uninitialized permanent moped :: BSON on rails 4 applications on geroku

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

ActionView::Template::Error (uninitialized constant Moped::BSON): 3: %nav.navbar-collapse 4: %ul.nav 5: %li 6: - if user_signed_in? 7: = link_to 'Logout', destroy_user_session_path, :method=>'delete' 8: - else 9: = link_to 'Login', new_user_session_path app/views/layouts/_navigation.html.haml:6:in `_app_views_layouts__navigation_html_haml___1118031947301940708_70104067139880' app/views/layouts/application.html.haml:18:in `_app_views_layouts_application_html_haml__1093647294459268715_70104069850820' 

The same error occurs in other haml files when accessing current_user - if current_user ...

+6
source share
3 answers

The following worked for me:

add to gemfile:

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

install package

add to application.rb:

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

From: https://github.com/mongoid/mongoid/issues/3455

+11
source

This error can also be caused by a reference to Moped::BSON in serialized cookies / session. Then deletes cookies.

+5
source

Check out this comment by Moped from Moped 2.0.0 (this is the version at the time of this writing, used as a driver in mongoid 4.0.0):

 Moped 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

+5
source

All Articles