【发布时间】:2016-01-07 14:22:02
【问题描述】:
我正在尝试为我的 Rails 应用程序实现 JSON API。它需要定义attributes 字段。但是ActiveModel::Serializer 有一个同名的方法,因此
class FooSerializer < ActiveModel::Serializer
attributes :attributes
def attributes
{
# to be filled
}
end
end
只会覆盖原来的方法。是否有可能以某种方式添加 attributes 字段?
【问题讨论】:
标签: ruby-on-rails-4 active-model-serializers