demarches-normaliennes/app/serializers/champ_serializer.rb

16 lines
297 B
Ruby
Raw Normal View History

2018-02-09 17:38:30 +01:00
class ChampSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
2018-02-09 17:38:30 +01:00
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
2018-02-09 17:38:30 +01:00
end