重複の可能性:
2 つの配列をハッシュに結合する
I have an model which stores key value pairs as attributes for another model person.
What is a simple way of turning person.person_attributes into a hash?
This is a stupid way I came up with:
keys = person.person_attributes.map(&:key)
values = person.person_attributes.map(&:value)
hashed_attributes = Hash.new
keys.each_index do |i|
hashes_attribues[keys[i]] = values[i]
end
What is a more elegant way to do this?
Thank you in advance,