2012-08-13 76 views
2

我正在使用Rails 3.1并开发了一年半的时间。今天早上我一定做了一些事情,现在好像我的很多文件似乎都被缓存了。这包括视图文件,控制器和模型。Rails:控制器和模型似乎被缓存在开发中

我可以在模型,控制器等进行更改,它不会对我的应用程序(在本地主机上运行:3000)产生任何影响。我试图切换端口(例如本地主机:3005),但它没有工作。

我没有改变任何配置文件或在我的电脑(Mac,Lion)上做出任何大的改动,但显然我必须做点什么。

  • 我在开发模式
  • 我在Mac
  • 公共文件夹是空的,除了
  • 我删除了/缓存/资产文件夹
  • 404页等使用的TextMate工作
  • 我已经删除了我的浏览器上的缓存

重新启动服务器使其工作,总是!有时(非常少见)更改会在不重新启动的情况下生效。

这是我development.rb:

# Settings specified here will take precedence over those in config/application.rb 

    # In the development environment your application's code is reloaded on 
    # every request. This slows down response time but is perfect for development 
    # since you don't have to restart the web server when you make code changes. 
    config.cache_classes = false 

    # Log error messages when you accidentally call methods on nil. 
    config.whiny_nils = true 

    # Show full error reports and disable caching 
    config.consider_all_requests_local  = true 
    config.action_controller.perform_caching = false 

    # Don't care if the mailer can't send 
    config.action_mailer.raise_delivery_errors = false 

    # Print deprecation notices to the Rails logger 
    config.active_support.deprecation = :log 

    # Only use best-standards-support built into browsers 
    config.action_dispatch.best_standards_support = :builtin 

    # Raise exception on mass assignment protection for Active Record models 
    config.active_record.mass_assignment_sanitizer = :strict 

    # Log the query plan for queries taking more than this (works 
    # with SQLite, MySQL, and PostgreSQL) 
    config.active_record.auto_explain_threshold_in_seconds = 0.5 

    # Do not compress assets 
    config.assets.compress = false 

    # Expands the lines which load the assets 
    config.assets.debug = true 

什么可能会发生,如何解决或解决呢?

+0

设置“config.cache_classes =真”,然后回到虚假似乎暂时解决了这个问题......可能是一个线索? – Christoffer 2012-08-13 11:39:46

+0

你是否设法解决这个问题,我们发生了完全相同的事情,它似乎是计算机专用的。在我的电脑上,它在我的同事电脑上工作,它不断缓存课程。 – DickieBoy 2012-08-23 16:42:35

回答

2

你可能没有看着你认为你在看什么。最常见的原因是:您在运行应用程序时查看项目的副本,而不是正在查看的文件夹。

或者你搞砸了你的development.rb(config.cache_classes = false)。

缓存提示:此页面包含所有缓存技术。看一下关于页面缓存的问题(它甚至没有通过Ruby堆栈运行)。

http://guides.rubyonrails.org/caching_with_rails.html

其他提示:整个项目复制到一个新的文件夹,所以由OS的任何文件夹魔术不会干扰。

开发日志没有透露有关正在发生的事情的任何提示吗?特别是如果你把索姆非法代码放在你的主要模型之一(真的应该崩溃)...

+0

不,这不可能,因为大多数视图(即application.html.erb)都可以正常工作...... – Christoffer 2012-08-13 11:16:31

+0

哦,并且config.cache_classes应该设置为false,对吧? (这是给我的,我没有改变它)。 – Christoffer 2012-08-13 11:19:58

+0

如果第二个不是真的(你的假设是正确的),第一个必须是真的。您未编辑用于生成网页的文件。你是从最近的列表编辑,并从命令行开始?打开文件,而不使用最近的列表,并仔细检查你的路径... – 2012-08-13 11:50:48

2

我已经有同样的问题。

添加下面一行在我development.rb文件我的问题已经得到解决后:

config.reload_classes_only_on_change = false 

我不明白为什么这个问题与高速缓存来了。在这两个星期里,一切工作都很顺利。

我使用的TextMate,也许......