-
-
Save ecnalyr/fd4c6f3916ff93abd39af6131c8f363f to your computer and use it in GitHub Desktop.
This file contains 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
# Fetches the responses and uses the first N elements of the array | |
# where N is the same number of associated_objects the parent object has. | |
def responses_and_associated_objects | |
# response is hard-coded for demonstration purposes | |
response = {"something":[123,456,789,101112,0,0,0,0,0,0,0,0]} | |
# this next line is ugly, thoughts? | |
response['something'][0..associated_objects.count-1] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe this?
associated_objects.map.with_index{|associated_object, index| response['something'][index]}