我想里面有葡萄的实体文件中的多个类的每个实体,这是文件夹结构的应用程序/ API /凸出/ API/V2 /实体/ 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
和内葡萄API
present @committees, with: PROJ::API::V2::Entities::Committee
正在工作。但如果我与
present @committees, with: PROJ::API::V2::Entities::CommitteeList
这是行不通的。但是,当我将它移动到一个名为committee_list.rb
的实体内部的新文件时它会起作用。
随着文件结构的工作为我好,但如果我有结构这样它不工作https://gist.github.com/anbublacky/a6e66217b2fcdeb52fe580864beecf7f –
更新要点请根据要点 –
更新答案 – anothermh