使用AJAX进行Rails搜索

I'm trying to implement the search function of the following rails cast: http://railscasts.com/episodes/240-search-sort-paginate-with-ajax

But the thing is im using rails 4 and i can't seem to get it to work.

For instance this line of code doesn't seem to be executed at all:

$("#products").html("<%= escape_javascript(render("products")) %>");

But according to the tutorial it should be placed in the file: app/views/controllername/index.js.erb

which seems strange to me as well.

Thanks for helping out

EDIT: I forgot to mention that I'm using the following route for the controller im using.

type_regexp = Regexp.new([:courses, :institutes, :programmes, :staff].join("|"))
resources :browse_courses, only: [:show, :index], path: ':type', constraints: { type: type_regexp }

Im using one controller to display the information stored in 4 models and one of the four models is shown depending on the param :type

try using

$("#products").html("<%= escape_javascript(render('products')) %>");  

the products should be in single quotes rather than double quotes.