Forum: Ruby on Rails Add hash to serialized column

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Alex (Guest)
on 2008-10-10 10:49
(Received via mailing list)
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.
Erol F. (Guest)
on 2008-10-10 10:58
(Received via mailing list)
On Oct 10, 8:22 am, Alex <removed_email_address@domain.invalid> wrote:
> >> u = User.find(1)
>
> Take care.

u.preferences.merge!({:test => 1})
Alex (Guest)
on 2008-10-10 11:05
(Received via mailing list)
Of course! Thank you very much.
This topic is locked and can not be replied to.