-
Notifications
You must be signed in to change notification settings - Fork 9
Usage
So, you want to use your first flex column? Here are the steps:
-
Pick (or add) a column to use as your flex column. This can be called anything (although watch out for the reasonably obvious name of "attributes"; it's reserved by ActiveRecord and weird, weird errors will result). This can be of any textual type (
CHAR
,VARCHAR
,TEXT
,CLOB
), in which case you'll get pure JSON in your column, or of a binary type (BINARY
,VARBINARY
,BLOB
), in which case you'll get a small header (FC:01,0,
or similar) in front of your data, followed by UTF8-encoded JSON. If you're using PostgreSQL, you can also use its nativeJSON
data type, in which case you'll get pure JSON, too. -
In the model class for that table, declare a flex column with any fields you want, like so:
class User < ActiveRecord::Base flex_column :user_attributes do field :foo field :bar end end
-
You're all ready to go.