I would expect to get json with both the name and note fields. But I only get the note field. What am I doing wrong?
class OrderPage
module Entities
class AsSeller < OrderPage::Entities::Order
expose :note
def note
object.note
end
end
end
end
class OrderPage
module Entities
class Order < Grape::Entity
expose :name
end
end
end
json = OrderPage::Entities::AsSeller.represent(order).as_json
Actually in your case you should receive an error on your third row
But changing the order, making
class Orderdefined higher thanclass AsSeller— all looks good, the JSON is rendered with both fields.If that doesn't help you can also try updating gem versions.