0
如果使用Active Model Serializers
產生在Rails JSON API,見RailsCast 409,並定義serializer
這樣的..主動型串行產生錯誤的ID
class ArticleSerializer < ActiveModel::Serializer
attributes :id, :name, :content
end
..和嘗試序列化對象(通常由render :json => article
):
ArticleSerializer.new(article).as_json
=> {:id=>158655280, :name => "a name", :content => "article content"}
那麼它有時會產生非常怪異標識和警告:Object#id will be deprecated; use Object#object_id
,至少對Ruby 1.8.7,1.9.3紅寶石似乎工作。
這是Ruby問題嗎?
如果更新到Ruby 1.9.3不是一個選項,你該如何解決它?