未初始化的常量Moped :: BSON在Heroku上的rails 4应用程序中 [英] uninitialized constant Moped::BSON in rails 4 app on heroku
本文介绍了未初始化的常量Moped :: BSON在Heroku上的rails 4应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<$ c $我从本地更新了rails 3到rails 4。 c> ActionView :: Template :: Error(未初始化的常量Moped :: BSON):
3:%nav.navbar-collapse
4:%ul.nav
5:%li
6: - 如果user_signed_in?
7:= link_to'注销',destroy_user_session_path,:method =>'删除'
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'
当我访问current_user
- 如果current_user
...
时,其他haml文件中会出现同样的错误
解决方案
以下工作适用于我:
添加到Gemfile:
gembson
gemmoped,github:mongoid / moped
捆绑安装
添加到application.rb:
要求bson
要求moped
Moped :: BSON = BSON
回答:
< a href =https://github.com/mongoid/mongoid/issues/3455> https://github.com/mongoid/mongoid/issues/3455
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 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 I access current_user - if current_user ...
解决方案
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
这篇关于未初始化的常量Moped :: BSON在Heroku上的rails 4应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文