demarches-normaliennes/app/serializers/champ_serializer.rb
2018-04-24 20:29:25 +02:00

15 lines
297 B
Ruby

class ChampSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
attributes :value
has_one :type_de_champ
def value
if object.piece_justificative_file.attached?
url_for(object.piece_justificative_file)
else
object.value
end
end
end