Skip to content

Instantly share code, notes, and snippets.

@zlw
Created June 9, 2012 14:35
Show Gist options
  • Save zlw/2901202 to your computer and use it in GitHub Desktop.
Save zlw/2901202 to your computer and use it in GitHub Desktop.
class Product < ActiveRecord::Base
def price
data && data['price']
end
def price=(val)
self.data = (data || {}).merge(price: val)
end
def weight
data && data['weight']
end
def weight=(val)
self.data = (data || {}).merge(weight: val)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment