论坛首页 编程语言技术论坛

rescue_action_in_public不起作用?

浏览 2706 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-10-25  
参考别人的sample,在applicatin.rb增加rescue_action_in_public方法定义:
class ApplicationController < ActionController::Base
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_mingle_session_id'
  def rescue_action_in_public(exception)
    render :file=>"#{RAILS_ROOT}/public/500.html"
  end
end


修改config=>config.action_controller.consider_all_requests_local = false

启动server,然后输入http://localhost:3000/aaa,但这个方法没有起作用,依然显示:

Routing Error
no route found to match "/aaa" with {:method=>:get}

还需要做什么设定呢?
   发表时间:2007-10-25  
自己找到答案了,在本机访问不调用rescue_action_in_public,如果本机访问需要在application.rb定义
def local_request? 
   false 
end
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics