Ruby on rails 如何在散列的余烬数组中生成
我是新来的 我有这个函数Ruby on rails 如何在散列的余烬数组中生成,ruby-on-rails,ember.js,coffeescript,Ruby On Rails,Ember.js,Coffeescript,我是新来的 我有这个函数 producerTypes: ( -> types = @get('model.registrations').mapBy('type').compact().uniq() //Here array of hashes to types and another model call requirements ).property('model.registrations') 如何在余烬中生成哈希数组 谢谢’:) producerRequirement
producerTypes: ( ->
types = @get('model.registrations').mapBy('type').compact().uniq()
//Here array of hashes to types and another model call requirements
).property('model.registrations')
如何在余烬中生成哈希数组
谢谢’:)
producerRequirements: ( ->
documentation = []
types = @get('model.registrationsDocumentations').
mapBy('producerType').compact().uniq() //first map by type
for producerType in types
requirements = @get('model.registrationsDocumentations').
filterBy('producerType', producerType) //second filter by producerType
documentation.addObject( //add to the array
producerType: producerType,
requirements: requirements
)
documentation
).property('model.registrationsDocumentations.@each')