user1560922
user1560922

Reputation: 267

Ruby on rails -- Render partial file inside .js.erb file

In the HTML header this small javascript works:

application.html.erb

<script type="text/javascript">
               alert("<%= escape_javascript(render('resources/positions')) %>");
</script>

But When I tried to put the same code in a js.erb file, it doesn't work.

I tried to inlcude the file, but not working both ways:

<script src="/assets/resources.js.erb" type="text/javascript"></script>
<%= javascript_include_tag 'resources' %>

app/assets/javascripts/resources.js.erb

alert("<%= escape_javascript(render('resources/positions')) %>");

any ideas ?

Thanks in advance for any help.

Upvotes: 1

Views: 1095

Answers (1)

Anthony Alberto
Anthony Alberto

Reputation: 10395

Sounds like a problem with the asset pipeline.

Try adding

config.serve_static_assets = true

In development.rb

Upvotes: 1

Related Questions