Skip to content Skip to sidebar Skip to footer

Ruby On Rails Asset Pipeline Doesn't Work Properly

I have been working on a ruby on rails project just now. I have created a controller named 'animals' and a view (index.html.erb) for index action. I don't want to include 'applicat

Solution 1:

I think your issue might be that you have two files with the same name (but different extensions). Since the Rails asset helpers treat coffescript and js files equally this is ambiguous:

<%= javascript_include_tag 'animals', 'data-turbolinks-track' => true %>

Which file should it load? I'm guessing it takes the first in alphabetical order which would be animals.coffee.

To solve the issue move the sprockets manifest to animals.coffee and remove the animals.js file.

# app/assets/animals.coffee#= require jquery#= require jquery_ujs#= require turbolinks#= require bootstrap-sprockets#= require_self
alert 'Hello World'

Solution 2:

You can remove the animals.coffee file and animals.js can be require in the file of application.js to available your js code in your project.

Post a Comment for "Ruby On Rails Asset Pipeline Doesn't Work Properly"