From 927e98621983d33795a99434492c3bb8ee7cd764 Mon Sep 17 00:00:00 2001 From: Marc Rendl Ignacio Date: Tue, 27 Jun 2017 17:10:26 +0800 Subject: Document ActiveRecord's PostgreSQL-specific support for JSONB datatype in RailsGuides [ci skip] --- guides/source/active_record_postgresql.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'guides/source') 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") # => #"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 -- cgit v1.2.3