ActionView :: Template :: Error(不能转储单例)

时间:2016-05-02 10:49:15

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4

我正在使用gem'jbuilder_cache_multi'来缓存我的json响应。当我从我的ios原生应用程序中点击我的api时遇到一个奇怪的错误。以下是我得到的错误:

ActionView::Template::Error (singleton can't be dumped):
2:
3: json.orders do
4:   json.cache! ['v1', I18n.locale, @orders] do
5:     json.cache_collection! @orders, key: ['v1', I18n.locale] do |order|
6:       json.partial! 'order', order: order
7:     end
8:   end

app/views/api/v1/orders/index.json.jbuilder:5:in `block (2 levels) in 

请求是:

Started GET "/api/v1/orders?page=2&q%5Bmerchant_id_eq%5D=1&q%5Bs%5D=created_at+asc&q%5Bstate_not_in%5D%5B%5D=composing&q%5Bstate_not_in%5D%5B%5D=distributed&q%5Bstate_not_in%5D%5B%5D=canceled" 

任何人都可以在这方面提供帮助。感谢

1 个答案:

答案 0 :(得分:1)

您要返回的其中一个字段可能是nil。你需要to_s它。请仔细研究这些价值观。