有一个包含“列表”的应用程序 - 认为是分类广告 - 每个列表都有一个标签列表。生产环境中运行RoR应用程序的问题
当我运行在生产模式下的应用程序下面的代码会失败,但在开发模式
uninitialized constant ActiveRecord::Acts::Taggable::InstanceMethods::TagList
Extracted source (around line #45):
42:
43: <span class="listingIndexTags">
44: Location: [location] | Tags:
45: <% tag_list = listing.tag_list %>
46: <% if tag_list != nil %>
47: <% for tag in tag_list %>
48: <%= link_to tag.to_s, { :action => "filter_on",
我使用开始我的杂种比如在这个测试用例命令行正常工作: Ruby脚本/ server mongrel -e production
默认为端口3000.我可以在应用中访问其他视图请勿调用“listing.tag_list”。
“.tag_list”由我在此应用中使用的“acts_as_taggable_on_steroids”提供。它作为宝石安装。
也许我的环境文件不通?
这是我的development.rb文件
config.cache_classes = false
config.whiny_nils = true
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
...took these settings out for this post...
}
而且我production.rb文件...
config.cache_classes = true
config.threadsafe!
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.cache_store = :mem_cache_store
config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
...took these settings out for this post...
}
这几乎肯定与cache_classes设置有关。要缩小范围,如果关闭生产中的类缓存会发生什么情况?另外,你使用的是什么版本的Rails? –
如果删除并重建数据库,则可能会在开发机器上显示该错误。我经常遇到这样的问题,这是因为开发数据库包含的旧条目满足应用程序的某些需求,但生产数据库不包含它们,因为它是新鲜的。有时候随着应用程序的增长,我们改变代码的方式是,当数据库为空时它会失败,如果其他所有的失败都只是一个黑暗的镜头。 – stephenmurdoch
另外,你有什么样的测试(特别是集成)?如果您的测试足够并且通过了 – stephenmurdoch