Skip to content

Instantly share code, notes, and snippets.

@betogrun
Created December 13, 2016 18:54
Show Gist options
  • Save betogrun/a530d03db801331e7669e377b20f1cf6 to your computer and use it in GitHub Desktop.
Save betogrun/a530d03db801331e7669e377b20f1cf6 to your computer and use it in GitHub Desktop.
def set_items
items_params = []
params['barter'].each do |barter|
barter['items'].each do |items|
items_params << Item.new(amount: items['amount'], kind: items['kind'], survivor_id: barter['survivor_id'] )
end
end
@items_to_barter_a = items_params.select { |key, value| key.survivor_id == @survivors[0].id }
@items_to_barter_b = items_params.select { |key, value| key.survivor_id == @survivors[1].id }
end
def set_survivors
@survivors = params['barter'].map { |survivor| Survivor.find(survivor['survivor_id']) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment