Slide 15
Slide 15 text
購入情報を一括で取得する
class Story < ApplicationRecord
#...
bulk_loader, :purchased? do |ids, user_id|
next {} if user_id.nil?
# APIで購入の有無を問い合わせ
purchased_story_ids =
Store::App::OrderedEpisodes.get(user_id, ids)
# {id => purchased?} という形式のHashに変換
ids.index_with {|id| purchased_story_ids.include?(id) }
end
end