Rails Search 3.2 Returns all instead of specific Query I have a simple search method installed in my Rails app that I want to be called from ajax, in another controller view.
Right now one looks like so:
class CensusController < ApplicationController

def search
  @census = Census.where("'NBRHD_NAME' like ?", "%#{params[:search]}%")

  render :json => @census.to_json
end

end

And in my other View/Controller
 google.maps.event.addListener(kmlLayer, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.name;
var offset = kmlEvent.latLng;
showInInfoWindow(text, offset);
map.panTo(kmlEvent.latLng);
map.setZoom(13);
//console.log(kmlEvent);
showInContentDiv(text);
    });

    function showInInfoWindow(text, offset) {
var content = "<div>" + text + "</div>";
var infoWindow = new google.maps.InfoWindow({
content: content,
position: offset
});
infoWindow.open(map);

    }

    function showInContentDiv(neighborName) {
var query = neighborName;
var url = "census/search?query=" + query;

$.getJSON(url, function(data) {
console.log(url);

var neigh = data;

for (var i in neigh.object)
{
console.log(neigh);
}
});

I just want the neighborhood name returned and matched to the one in my database, instead all Database names are returned in the JSON format.  Is there something I am doing wrong?
Again I am running Rails 3.2 with MySQL2 gem

SQL uses single quotes for string literals so this query:
@census = Census.where("'NBRHD_NAME' like ?", "%#{params[:search]}%")

is really asking for all rows where the string literal 'NBRHD_NAME' contains params[:search]. Presumably you want to look at the column NBRHD_NAME rather than the string 'NBRHD_NAME' so you should say:
@census = Census.where("`NBRHD_NAME` like ?", "%#{params[:search]}%")

or
@census = Census.where("NBRHD_NAME like ?", "%#{params[:search]}%")

AFAIK, MySQL's case sensitivity for columns depends on the configuration so you should use the backticked version to be safe if you're working with column names that really were created in upper case. Note that backtick-quoting for SQL identifiers is a MySQLism, standard SQL uses double quotes ("NBRHD_NAME") for such purposes and SQL Server uses brackets ([NBRHD_NAME]).

I just noticed this in your JavaScript:
var url = "census/search?query=" + query;

That would suggest that params[:query] contains what you're looking for but your controller is looking at params[:search]. The result is that your SQL says like '%%'. So fix up your quoting and then look at the right thing in params:
@census = Census.where("`NBRHD_NAME` like ?", "%#{params[:query]}%")