aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/active_record_postgresql.md
diff options
context:
space:
mode:
authorviditn91 <vidit@vinsol.com>2014-09-03 02:31:00 +0530
committerviditn91 <vidit@vinsol.com>2014-09-03 02:31:00 +0530
commit6d988e2a29fa898176adeef6936e6032a221e4fd (patch)
tree73b4730f4a02ab76a90024618e1b5f55d07610d3 /guides/source/active_record_postgresql.md
parenta2f8377d1dd66c200a9a8d31db14f2b0a4bec744 (diff)
downloadrails-6d988e2a29fa898176adeef6936e6032a221e4fd.tar.gz
rails-6d988e2a29fa898176adeef6936e6032a221e4fd.tar.bz2
rails-6d988e2a29fa898176adeef6936e6032a221e4fd.zip
use correct operator in query based on JSON document
Diffstat (limited to 'guides/source/active_record_postgresql.md')
-rw-r--r--guides/source/active_record_postgresql.md3
1 files changed, 2 insertions, 1 deletions
diff --git a/guides/source/active_record_postgresql.md b/guides/source/active_record_postgresql.md
index a5649e3903..6c94218ef6 100644
--- a/guides/source/active_record_postgresql.md
+++ b/guides/source/active_record_postgresql.md
@@ -132,7 +132,8 @@ event = Event.first
event.payload # => {"kind"=>"user_renamed", "change"=>["jack", "john"]}
## Query based on JSON document
-Event.where("payload->'kind' = ?", "user_renamed")
+# The -> operator returns the original JSON type (which might be an object), whereas ->> returns text
+Event.where("payload->>'kind' = ?", "user_renamed")
```
### Range Types