ruby Rails 缓存
我在我的控制器中使用此代码
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:Class 的未定义局部变量或方法“response”
有什么建议吗?
I am using this code insite my controller
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>"
The caching is working properly, and my webapp does support subdomains.
When I browse to mysubdomain.something.com it gives me an "Routing Error"
undefined local variable or method `response' for ProjectsController:Class
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这段代码应该位于某个方法的内部。
response
在类级别不存在或没有意义。This code is supposed to be inside of some method.
response
doesn't exist or make sense at class level.