Skip to content

Instantly share code, notes, and snippets.

@ukd1
Created October 8, 2020 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ukd1/fabab771d5c6f5a9e31007ca625aa69d to your computer and use it in GitHub Desktop.
Save ukd1/fabab771d5c6f5a9e31007ca625aa69d to your computer and use it in GitHub Desktop.
class MyModel
def my_column
if self.has_attribute?(:my_column_JSON)
self.my_column_JSON
else
self.attributes[:my_column]
end
end
def my_column=(value)
if self.has_attribute?(:my_column_JSON)
self.my_column_JSON = value
else
self.attributes = { my_column: value }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment