I have a User Model with a database field 'remark'. I am using Postgres as Database and the 'remark' field is of type HSTORE. So 'remark' stores a hash with extra user information.
As suggested by someone I added a store to my 'User' model like this:
class User < ActiveRecord::Base
store :remark, accessors: [ :info ]
#some code
end
Now I can get the value in @user.remark['info'] by using this accessor '@user.info'. That works fine. But when I try to set and save a new value like this:
@user.info = "some info"
@user.save
I get the following error:
ActiveRecord::StatementInvalid: PG::InternalError: ERROR: Syntax error near '!' at position 4
Is it possible to use a HSTORE type databasefield this way? What am I doing wrong?
@user.remark['info'] = "some info"; @user.save?