I want to have multiple classes inside grape entity file, this is the folder structure 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
and inside the grape api
present @committees, with: PROJ::API::V2::Entities::Committee
is working. but if i present with
present @committees, with: PROJ::API::V2::Entities::CommitteeList
it is not working. But it works when i move it to a new file named committee_list.rb inside entities.
Aucun commentaire:
Enregistrer un commentaire