【发布时间】:2015-03-26 05:40:26
【问题描述】:
我已经创建了葡萄实体:
class VehicleDetails < Grape::Entity
expose :id
expose :name
expose :type
expose :health, if: {type: 'basis'}
end
如果当前:type 等于basis,我想公开:health。我尝试通过这种方法访问它:
get :details do
present Basis.all, with: GameServer::Entities::VehicleDetails
end
Health 属性未显示在我创建的 json 中。我想我可以使用expose :health, if: :health,它也不起作用。我做错了什么???
【问题讨论】:
标签: ruby-on-rails ruby json grape-api grape-entity