【发布时间】:2014-04-23 14:11:32
【问题描述】:
我正在尝试在我的 Ruby 2.1.1/Rails4.1.0 应用程序上为 Rabl json 模板启用缓存。这是
在我的 config/development.rb 中
config.action_controller.perform_caching = true
在我的 app/controllers/phones_controllers.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/phones/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 进行缓存的更多信息,但收效甚微,谁能指出我在哪里寻找或有这方面经验的正确方向?
谢谢!
【问题讨论】:
-
你能解决这个问题吗?
-
不,我仍然无法解决这个问题。
标签: ruby-on-rails caching ruby-on-rails-4 rabl