0

Im trying to add a hash to an array like this :

rejects = self.user.rejects
rejects << {name: self.originalname, reason: reason}

User rejects is an array. Here's the migration line :

t.string :rejects, array: true, default: []

But I get something like this as the output :

["{:name=>\"wallhaven-56800.jpg\", :reason=>\"Quality not good enough\"}"]

How can I fix this?

THpubs
  • 7,154
  • 13
  • 60
  • 133

1 Answers1

0

I would try something like this:

rejects = []

#inside your loop:
the_hash = {}
the_hash[:name] = self.original_name
the_hash[:reason] = reason
rejects << the_hash

That may not be the most efficient, I'm sure you could get it all on one line even, but that is a good start.

Stephen
  • 197
  • 7