Add hash to serialized column


#1

Hey guys,

I’m trying to merge a hash with another using the .merge! function.

class User < ActiveRecord::Base
serialize :preferences
end

This is what I end up with in the console:

u = User.find(1)
u.preferences.merge!{:test => 1}
SyntaxError: compile error
(irb):32: syntax error, unexpected tASSOC, expecting ‘}’
u.preferences.merge!{:test => 1}
^
from (irb):32
from :0

Any ideas?

Take care.


#2

On Oct 10, 8:22 am, Alex removed_email_address@domain.invalid wrote:

u = User.find(1)

Take care.

u.preferences.merge!({:test => 1})


#3

Of course! Thank you very much.