aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorMarc Rendl Ignacio <marcrendlignacio@gmail.com>2017-06-27 17:10:26 +0800
committerMarc Rendl Ignacio <marcrendlignacio@gmail.com>2017-06-27 17:11:50 +0800
commit927e98621983d33795a99434492c3bb8ee7cd764 (patch)
tree8da425cf4c686d83b86ecb77394d4056b71c910b /guides
parent61cc630ac7e7f8554dc049a3e5a2509c00303ef8 (diff)
downloadrails-927e98621983d33795a99434492c3bb8ee7cd764.tar.gz
rails-927e98621983d33795a99434492c3bb8ee7cd764.tar.bz2
rails-927e98621983d33795a99434492c3bb8ee7cd764.zip
Document ActiveRecord's PostgreSQL-specific support for JSONB datatype in RailsGuides
[ci skip]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_postgresql.md7
1 files changed, 6 insertions, 1 deletions
diff --git a/guides/source/active_record_postgresql.md b/guides/source/active_record_postgresql.md
index 041fdacbab..8543fcd20f 100644
--- a/guides/source/active_record_postgresql.md
+++ b/guides/source/active_record_postgresql.md
@@ -114,16 +114,21 @@ Profile.where("settings->'color' = ?", "yellow")
# => #<ActiveRecord::Relation [#<Profile id: 1, settings: {"color"=>"yellow", "resolution"=>"1280x1024"}>]>
```
-### JSON
+### JSON and JSONB
* [type definition](http://www.postgresql.org/docs/current/static/datatype-json.html)
* [functions and operators](http://www.postgresql.org/docs/current/static/functions-json.html)
```ruby
# db/migrate/20131220144913_create_events.rb
+# ... for json datatype:
create_table :events do |t|
t.json 'payload'
end
+# ... or for jsonb datatype:
+create_table :events do |t|
+ t.jsonb 'payload'
+end
# app/models/event.rb
class Event < ApplicationRecord