Tom
Tom

Reputation: 797

Rails js is not executed

In assets/javascripts/blog.js.coffee

console.log('123')

When page is loaded, this is in html (development mode):

<script src="/assets/blog.js?body=1" type="text/javascript"></script>

Content of this file:

(function() {

  console.log('123');

}).call(this);

But when page is loaded browser console is empty, this means that js is not executed.

In what could be the problem? Thanks in advance for your reply.

Upvotes: 0

Views: 86

Answers (1)

deefour
deefour

Reputation: 35360

You can't expect invalid Coffeescript to produce expected results.

Rename your file to assets/javascripts/blog.js or change the content of the file to

(->
  console.log "123"
).call this

Upvotes: 2

Related Questions