Rails dynamic attribute in where LIKE clause
<p>I have a search method, which takes in a key value pair in argument and searches on an active record model via a LIKE query. But I am unable to get it to work. It doesn't take the key argument properly.</p>

<p>This is what my method looks like:</p>

<pre><code>def search(key,value)
  where('? LIKE ?',key,"%#{value}%")
end
</code></pre>

<p>The query it fires is <code>('name' LIKE '%air%')</code> whereas it should fire <code>(name LIKE '%air%')</code></p>

<p>Is there a way I could get this to work?</p>