하나의 파일에있는 각 개체,이 폴더 구조 응용 프로그램/API/PROJ/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
내부 Grape 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