Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render new.js.coffee.erb in app/views?

Using Rails 3.1 jquery_ujs, I have a link with :remote => true, and the controller new action responds with js and render new.js.erb which contains:

$('#post-form').html('<%= escape_javascript(render(:partial => "form")) %>'); 

It renders the _form.html.erb partial. This works.

Now I want to use Coffeescript, but renaming new.js.erb to new.js.coffee.erb doesn't work. Does the asset pipeline only work in app/assets? What am I doing wrong? Thanks.

like image 660
Raymond Law Avatar asked Sep 30 '11 21:09

Raymond Law


1 Answers

I had this same issue using Rails 3.1.0. Try renaming your file to just new.js.coffee. It should still render erb despite not having the extension on the filename.

It's definitely confusing that view templates don't follow the same conventions as the asset pipeline.

like image 153
cjbottaro Avatar answered Sep 18 '22 13:09

cjbottaro