我想裏面有葡萄的實體文件中的多個類的每個實體,這是文件夾結構的應用程序/ 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