Created
December 13, 2016 18:54
-
-
Save betogrun/a530d03db801331e7669e377b20f1cf6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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