Rails js.erb file cannot find method "render"
Solution 1:
You're trying to use render
from assets. Unfortunately, it isn't possible now, look at this.
Solution 2:
With the new asset pipeline, inside static assets (/app|lib|vendor/assets/
) you can use some 'static' helpers (i.e. <%= asset_path "/foo/bar" %>
), because you just compile them once (if you're on production i.e.) and not every time you make an http req. Therefore, it makes no sense to use methods like render
(or general 'dynamic' stuff) inside a static asset.
For your particular case, you could use both *.js.erb views (that will 'match' a particular action inside the controller) or javascript rendered directly inside the html.