Expand fix from e5de60d9fb to query variable

The fix for ruby 1.9+ needs to apply to "query", too. Not only "q".
Merge branch 'master' into rails-4

* master:
  Expand fix from e5de60d9fb to query variable