在生产环境中运行 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",
在这个测试用例中我用来启动我的 mongrel 实例的命令行: ruby script/server mongrel -e production
默认为端口 3000。我可以访问应用程序中不调用“listing.tag_list”的其他视图。
“.tag_list”由“acts_as_taggable_on_steroids”提供,我在这个应用程序中使用它。它作为 gem 安装。
也许我的环境文件很奇怪?
这是我的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...
}
和我的development.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...
}
Have an app that has "listings" - think classified ads - and each listing has a list of tags.
The following code fails when I run the app in production mode, but works fine under development mode
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",
The command line I'm using to start my mongrel instance in this test case:
ruby script/server mongrel -e production
Defaults to port 3000. I can access other views in the app that DON'T call "listing.tag_list".
".tag_list" is provided by "acts_as_taggable_on_steroids", which I'm using in this app. It is installed as a gem.
Maybe my environment files are wonky?
Here's my development.rb file
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...
}
And my production.rb file...
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...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来到这里遇到了同样的问题,只是想给遇到同样问题的每个人一个说明......我已经通过修复环境中的 gems 版本设法解决了这个问题。rb
改变了这个
config.gem "acts-as-taggable-on", :source =>; “http://gemcutter.org”
:
config.gem "acts-as-taggable-on", :source =>; "http://gemcutter.org", :version => '2.0.0.rc1'
并运行 rake gems:install
我想知道您是否以某种方式在不同的环境中运行不同的 gems(如果可能的话)。
Came along here with the same problem and just wanted to hand a note to everyone experiencing the same....I've managed to sort this problem this by fixing the version of gems in environment.rb
changed this
config.gem "acts-as-taggable-on", :source => "http://gemcutter.org"
to this:
config.gem "acts-as-taggable-on", :source => "http://gemcutter.org", :version => '2.0.0.rc1'
and run a rake gems:install
I wonder if you somehow were running different gems on different environments if that is possible.
您的生产服务器上是否安装了
acts_as_taggable_on_steroids
gem?Do you have the
acts_as_taggable_on_steroids
gem installed on your production server?已修复:
好吧,在推迟修复此错误直到我绝对必须(今天)之后,我终于找到了问题的根源。
该行的包含:
配置.线程安全!
在我的“生产.rb”文件中导致了它。
无论如何,当我添加“config.threadsafe!”时线路 - 断了!我从来没有这么高兴过应用程序中断。
因此,稍微阅读一下以了解此选项的确切作用,并与 Mongrel 结合使用(如果 Mongrel 甚至相关的话),我就会得到我的答案。
FIXED:
Well, after putting off fixing this bug until I absolutely had to (today), I at long last found the source of the issue.
The inclusion of the line:
config.threadsafe!
In my "production.rb" file was causing it.
Anyhow, when I got to adding the "config.threadsafe!" line - IT BROKE! I was never so happy to have an app break.
So, a little reading to understand what exactly this option does, in conjuction with Mongrel (if Mongrel is even relevant), and I'll have my answer.