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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -