ruby on rails - Accessing Serialized Hash via ActiveRecord -
i have serialized hash in mymodel, this:
class mymodel < activerecord::base serialize :times, hash end i able write , read serialzed hash, this:
# write my_model.times[:weekday] = "foo" # read bar = my_model.times[:weekend] but running syntax errors around times[:weekday], while trying this:
mymodel.where("foo = ? , times[:weekday] not null", baz) what missing here?
what about:
mymodel.where("foo = ?", baz).select { |m| m.weekday.present? } ?
Comments
Post a Comment