Closed
Description
Steps to reproduce
Create a new project and create any coffeescript.
Expected behavior
The script using jquery should work.
Actual behavior
Javascript error: $ is not defined.
System configuration
Rails version:
5.1.2
Ruby version:
2.3.3
Any script using jquery will fail, I think it would be expected to work with the included Coffeescript "compiler", as we usually use:
$ ->
define behavior here...
And this will not work, at least on Windows. I detected it using the Firefox debugger showing '$ is not defined', this is jquery not present.
I solved it:
- Install gem jquery-rails if not installed.
- Modify the application Gemfile, adding:
gem 'jquery-rails' - Adding to assets/javascript/application.js these lines:
//= require jquery3
//= require jquery_ujs
Just before the //= require rails-ujs.
Now all the coffeescripts work fine.
I think these 3 points should be added to the rails application generator by default.
Metadata
Metadata
Assignees
Labels
No labels