【发布时间】:2017-04-15 13:09:33
【问题描述】:
我想在葡萄实体文件中有多个类,这是文件夹结构app/api/proj/api/v2/entities/committees.rb
module PROJ::API::V2::Entities
class Committee < Grape::Entity
expose :id
expose :name, :full_name, :email, :tag, :parent_id
expose :country do |entity, option|
entity.parent.name if entity.parent.present?
end
# include Urls
private
def self.namespace_path
"committees"
end
end
class CommitteeWithSubcommittees < CommitteeBase
# include ProfilePhoto
expose :suboffices, with: 'PROJ::API::V2::Entities::CommitteeBase'
end
在 Grape API 内部
present @committees, with: PROJ::API::V2::Entities::Committee
正在工作。但如果我与
present @committees, with: PROJ::API::V2::Entities::CommitteeList
它不工作。但是当我将它移动到实体内名为committee_list.rb 的新文件时它可以工作。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 entity grape-api