我想解決爲什麼當我在工作的一個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