Class: ActiveRecord::ConnectionAdapters::TableDefinition
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::TableDefinition
- Defined in:
- lib/activerecord-postgres-json/activerecord.rb
Instance Method Summary collapse
-
#json(*args) ⇒ Object
Adds json type for migrations.
- #jsonb(*args) ⇒ Object
Instance Method Details
#json(*args) ⇒ Object
Adds json type for migrations. So you can add columns to a table like:
create_table :people do |t|
...
t.json :info
...
end
47 48 49 50 51 |
# File 'lib/activerecord-postgres-json/activerecord.rb', line 47 def json(*args) = args. column_names = args column_names.each { |name| column(name, 'json', ) } end |
#jsonb(*args) ⇒ Object
53 54 55 56 57 |
# File 'lib/activerecord-postgres-json/activerecord.rb', line 53 def jsonb(*args) = args. column_names = args column_names.each { |name| column(name, 'jsonb', ) } end |