Kasama
Kasama

Reputation: 83

Application.js is not being processed into final view

I have in my application.html.erb layout a line like this:

<%= javascript_include_tag 'application', media: 'all', 'data-turbolinks-track' => true %>

but in the html page sent to the browser I find only

<script src="/assets/application.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" media="all" data-turbolinks-track="true"></script>

which contains 'nothing'

(function() {

}).call(this);


In my /app/assets/javascripts/application.js I have

//= require jquery.min
//= require jquery_ujs
//= require bootstrap.min

and my /vendor/assets/javascripts/ include jquery.min.js and bootstrap.min

my Gemfile include

gem 'jquery-rails'
gem 'sprockets-rails'
gem 'turbolinks'

my workaround for now is to include the jquery and bootstrap javascripts directly with

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

Useful information

$uname -a
Linux Kasama 4.0.6-1-ARCH #1 SMP PREEMPT Tue Jun 23 14:25:08 CEST 2015 x86_64 GNU/Linux

$rails --version
Rails 4.2.3

$ruby --version
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

Source code for the whole application can be found here (any constructive critic is appreciated)


From what I've read from The Asset Pipeline, what I have should work properly, but it's not.


Side note: the application.css manifest gets loaded correctly and the bootstrap.css file gets sent to browser, the problem only happens with javascript files

Upvotes: 1

Views: 110

Answers (1)

dimakura
dimakura

Reputation: 7655

See In Development section of the doc:

http://guides.rubyonrails.org/asset_pipeline.html#in-development

In development mode, assets are served as separate files in the order they are specified in the manifest file.

Your js/css assets are there, in separated script/link tags.

Update In your case trouble was caused by application.coffee file which presents alongside with application.js. Removing it will fix your problem.

Upvotes: 1

Related Questions