2008年10月17日 星期五

rescue_action_in_public, local_request, 取消 local request

http://api.rubyonrails.com/classes/ActionController/Rescue.html#M000615
http://blog.hendrikvolkmer.de/2007/3/8/http-referer-and-redirect_to-back


[config/environments/development.rb]
config.action_controller.consider_all_requests_local = false

# force the request connect from outside
def local_request?
false
end

#有上面兩個條件rescue_action_in_public才可以在local測
def rescue_action_in_public(exception)
case exception
when ActionController::RoutingError
redirect_to home_url
else
super
end
end




<%= stylesheet_link_tag "defaults", "paginator", :cache => 'css_cache' %>
<%= javascript_include_tag "jquery", "jquery.corner.js", "jquerypngfix.js", :cache => 'js_cache' %>

上述的這些 :cache 功能 如果 client ip 是從 local來 就不會跑, 不會生出 css_cache.css 或 js_cache.js

沒有留言: