私のプロジェクトの要件により、ネストされたエンティティにパラメーターを渡す必要があります。いくつかの情報を表示するエンティティ A とエンティティ B があり、それらを構築するにはシステム上に A 識別子が必要です。
module Services
module Trips
class TripPreviewResponseEntity < Grape::Entity
expose :id
expose :title
expose :duration
expose :total_price
expose :description
expose :details
expose :destinations, using: Destinations::DestinationResponseEntity
end
end
end
上記の例では、次のようなことをしたいと考えています。
expose :destinations, using: Destinations::DestinationResponseEntity, :trip_id => object.id
ネストされたエンティティでは、次のように trip_id パラメータ オプションを使用します。
expose :trip_info do |item,options|
item.show(options[:trip_id])
end
しかし、オブジェクトがエンティティに定義されていないと言って失敗しています。これを実行する方法はありますか?何か案が?