Last active
June 3, 2017 01:25
-
-
Save mkhuda/b83d9e5732d12108e15118fae8455019 to your computer and use it in GitHub Desktop.
Creating Array of Hashes with Ruby
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 self.create_aoh | |
| aoh_hash = { project: [] } | |
| self.all.each do |order| | |
| aoh_hash[:orders] << { | |
| text: order.texts.pluck(:id), | |
| text_count: order.texts.pluck(:words), | |
| doc: order.documents.pluck(:id), | |
| doc_count: order.documents.pluck(:words) | |
| } | |
| end | |
| return aoh_hash[:project] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment