我有一个资产模型类,它使用回形针 3.5.2 具有不同的大小:
class AssetSerializer < ActiveModel::Serializer
attributes :id, :asset # works fine
# would like to output small but don't seem to be able to
#attributes :id, :asset, :asset(:small)
end
这有点令人困惑,因为 Paperclip 使用名称类,而模型称为类(确实令人困惑)。我收到以下错误:
/Users/jt/repos/rails/app/serializers/asset_serializer.rb:2: syntax error, unexpected '(', expecting keyword_end
attributes :id, :asset, :asset(:small)
它显然不喜欢传递给资产的论点