Answer the question
In order to leave comments, you need to log in
rails. How to add elements to an array in a hash?
Hi all.
There is a hash. The hash has an array like 'pictures'. How to add elements to an array?
hash = {'pictures' => [] }
someArray.each do |a|
hash['pictures'].push(a) # не работает :/
end
def check_docs(docs)
if docs.nil?
false
else
hash = {}
docs.each do |doc|
name = doc.original_filename.split('.').last
if pic(name) != false
hash['pictures'] = [] unless hash['pictures']
hash['pictures'] << doc
end
if doc(name) != false
hash['docs'] = [] unless hash['docs']
hash['docs'] << doc
end
end
if hash.size > 0
hash
else
false
end
end
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question