我正在尝试在我的Ruby 2.1.1/Rails4.1.0应用程序上为Rabl json模板启用缓存。它是
在我的config/development.rb
config.action_controller.perform_caching = true在我的应用程序/controllers/phones_Controlers.rb中
def show
@phone = Phone.find(params[:id])
respond_to do |format|
format.html # show.html.erb
# format.json { render json: @phone }
format.json
end
end最后,app/views/phone/show.json.rabl
object @phone
cache @phone
attributes :area, :number, :country, :id, :created_at, :updated_at, :phoneable_id, :phoneable_type我得到的错误是
Rendered phones/show.json.rabl (2.6ms)
Completed 500 Internal Server Error in 18ms
ArgumentError - wrong number of arguments (4 for 1):
rabl (0.9.3) lib/rabl/digestor.rb:8:in `digest'
rabl (0.9.3) lib/rabl/engine.rb:294:in `cache_key_with_digest'
rabl (0.9.3) lib/rabl/engine.rb:279:in `cache_results'
rabl (0.9.3) lib/rabl/engine.rb:39:in `render'
app/views/phones/show.json.rabl:2:in `_app_views_phones_show_json_rabl__914081420294741706_70254824188740'我花了一天的时间寻找更多关于使用Rabl缓存的信息,但收效甚微,有人能给我指出正确的方向吗?
谢谢!
发布于 2014-04-23 14:11:33
这个错误似乎是Rails 4.1.0中缓存摘要处理更改的结果。RABL已更新以修复此问题(https://github.com/nesquena/rabl/pull/540),但该修复目前仅作为预发布提供:
gem install rabl --prehttps://stackoverflow.com/questions/23045106
复制相似问题