time - Rails Hstore dateTime saving -


how use datetime values , store , retrieve them using hstore?

i using this:

module hstoreaccessor   def self.included(base)     base.extend(classmethods)   end    module classmethods     def hstore_accessor(hstore_attribute, *keys)       array(keys).flatten.each |key|         define_method("#{key}=") |value|           send("#{hstore_attribute}=", (send(hstore_attribute) || {}).merge(key.to_s => value))           send("#{hstore_attribute}_will_change!")         end         define_method(key)           send(hstore_attribute) && send(hstore_attribute)[key.to_s]         end       end     end   end end  activerecord::base.send(:include, hstoreaccessor) 

to define accessors , works great except dates. wierd stuff in test cases when compare date saved , retrieved model date model not yet saved. date before save "time" class , afterwards string.

i realize hstore keeps things strings have difficulties figuring out how serializes date can reverse same way in getter/setters field.

any appreciated. thanks.

it looks serializes using 'to_s', deserialize time instance time#parse should enough


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -