ruby - How to update hstore columns in Rails 4 -


Is there a way to restrict hstore columns to be saved? I've got the code to do so by now:

  store_accessor: widget_locations,: left_area1 ,: mid_area1,: left_area2,: mid_area2,: right_area2  

But it still allows to save other key names. update_attributes or update

/ P>

I may be wrong, but my guess is that you widget_locations

< Pre> item.widget_locations [: left_area1] = thing

If so, you can call it

  item.left_area1 = thing  > 

Because you have asked to create the store_accessor attributes : left_area1 ,: mid_area1,: left_area2,: mid_area2,: right_area2 The database will be serialized in the column : widget_locations . Now these attributes will behave like normal attributes, so that you can put the assumptions on them etc.

This lets you update an item as usual:

  item.update (name: 'test', left_area: 'garden', mid_area: 'livingroom ') Hold  

with a hstore will allow be to access the serial column to allow you to add new unknown features, so obvious The best way to reach the specified features is as follows.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -