我想解决为什么当我在工作的一个rails应用上工作时,要查看我对页面上的html所做的更改的唯一方法是使用ctrl-C
然后致电script/server
。为什么我每次都必须重新启动rails才能在这里测试404.html页面?
至于我可以告诉大家,我也看不出什么特别的毛病development.rb
配置文件的位置:
# Settings specified here will take precedence over those in config/environment.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 webserver 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.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = false
# add rack bug
# config.middleware.use "Rack::Bug"
# this disables the caching for comatose, not the rest of the app
# config.disable_caching = true
config.action_mailer.default_url_options = { :host => "localhost:3000" }
config.gem "thoughtbot-factory_girl",
:lib => "factory_girl",
:source => "http://gems.github.com"
这本身并不能在本地显示错误页面,所以在application_controller.rb
我已经别名rescue_action_locally
到rescue_action_in_public
方法,阻止我看到堆栈跟踪:
# this method allows you to test 404 and 500 pages locally
alias_method :rescue_action_locally, :rescue_action_in_public
在这里,这说明我的错误页面一次,但随后缓存,这样,以后重装显示HTML文件时,本身的状态rver被加载。
日志输出不告诉我任何奇怪的缓存行为 - 它得到的请求不存在的资源,没有找到任何东西,然后在渲染HTML页面的要求:
[email protected] ~/RailsApps/annoying_app > script/server --debugger
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
=> Debugger enabled
=> Call with -d to detach
=> Ctrl-C to shutdown server
SQL (0.2ms) SET SQL_AUTO_IS_NULL=0
Processing ApplicationController#index (for 127.0.0.1 at 2009-12-28 19:23:27) [GET]
ActionController::RoutingError (No route matches "/non-existent-resource" with {:method=>:get}):
Rendering /Users/chrisadams/RailsApps/annoying_app/public/404.html (404 Not Found)
404。 html完全是静态的,根本没有任何ERB,这个静态html页面是页面刷新之间不会改变的。
我在这里做错了什么?这真让我抓狂!
我不知道为什么,但使用'rescue_from'似乎已清除了这里的奇怪缓存问题。谢谢你的提示。 – 2009-12-29 10:14:36