我是新手,在生产模式下使用 mongodb(使用 mongoid)运行 rails 3 服务器时遇到了一些麻烦。在开发模式下一切正常,我无法弄清楚我错过了什么。请帮助我,非常感谢。这是错误:
ActionView::Template::Error(nil:NilClass 的未定义方法 `map'):
2: #control{:style => "float: left;"}
3: %h3= t(:manage_shop)
4: =# debugger
=###### Already checking @shops variable but still got error ######
5: = hidden_field_tag :shop_list, @shops.blank? ? "test" : @shops.to_json
6: = form_tag("/shop", :method => "POST", :id => "frm_create_shop") do
7: %table
8: %tr
app/views/shop/index.html.haml:5:in`_app_views_shop_index_html_haml___1855911541554609468_28040500'
这是我的行动:
def index
@shops = Shop.all
respond_to do |format|
format.html
end
end
我的模型:
class Shop
include Mongoid::Document
include Mongoid::Geospatial
field :id, type: Integer
field :name, type: String
field :position, type: Point, :spatial => true, :delegate => true
spatial_scope :position
end
和我的 production.rb 配置:
Trunk::Application.configure do
config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
end
第二件事是我无法从 db 获得任何东西,尽管一切都在开发模式下运行良好。如果您有什么建议,请帮忙,谢谢。