From 6d988e2a29fa898176adeef6936e6032a221e4fd Mon Sep 17 00:00:00 2001 From: viditn91 Date: Wed, 3 Sep 2014 02:31:00 +0530 Subject: use correct operator in query based on JSON document --- guides/source/active_record_postgresql.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guides') 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 -- cgit v1.2.3