Created
October 8, 2020 06:34
-
-
Save ukd1/fabab771d5c6f5a9e31007ca625aa69d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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