Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

How does one use bound variables when searching for keys? #88

Open
chrisbloom7 opened this issue Feb 20, 2013 · 1 comment
Open

How does one use bound variables when searching for keys? #88

chrisbloom7 opened this issue Feb 20, 2013 · 1 comment

Comments

@chrisbloom7
Copy link

chrisbloom7 commented Feb 20, 2013

Given your example Person.where("data ? 'foo'"), how would one rewrite that to use a bound variable? Person.where("data \? ?") results in ActiveRecord::PreparedStatementInvalid: wrong number of bind variables (1 for 2).

@davidbegin
Copy link

Instead of using ? use key/value pairs.

Person.where("date ? :key", :key => 'foo')

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants