2012-02-03 187 views
1

我使用此代碼INSITE我控制器紅寶石軌道緩存

class ProjectsController < ApplicationController 

    cache_expire = 60*60*24*365 
    response.headers["Pragma"] = "public" 
    response.headers["Cache-Control"] = "max-age=#{cache_expire}" 
    response.headers["Expires"] = Time.at(Time.now.to_i + cache_expire).strftime("%D, %d %M % Y %H:%i:%s") 
    render :layout => "application", 
      :inline => "<script src='//connect.facebook.net/en_US/all.js'></script>" 

緩存正常工作,而我的web應用程序不支持子域。

當我瀏覽到mysubdomain.something.com它給了我一個「路由錯誤」

未定義的局部變量或方法'響應」的ProjectsController:類

有什麼建議?

回答

2

該代碼應該是某種方法的內部。

def index 
    cache_expire = 60*60*24*365 
    response.headers["Pragma"] = "public" 
    response.headers["Cache-Control"] = "max-age=#{cache_expire}" 
    response.headers["Expires"] = Time.at(Time.now.to_i + cache_expire).strftime("%D, %d %M % Y %H:%i:%s") 
    render :layout => "application", 
     :inline => "<script src='//connect.facebook.net/en_US/all.js'></script>" 
end 

response在課堂上不存在或沒有意義。