Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.2.8 Application.js and Application.css are not working as expcted

When i try to include

<%= stylesheet_link_tag    "application" %>
<%= javascript_include_tag "application" %>

The content of the files of the application.css is:

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require social_stream
*= require_tree .
*/

And the content of application.js file is

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require social_stream-base
//= require social_stream-documents
//= require social_stream-events
//= require social_stream-linkser
//= require social_stream-presence
//= require social_stream-oauth2_server
//= require_tree .

my rails app is not including the css and js files those are required in the above snippet. but when i update the include tags to the specific file those are included fine. i.e.

<%= stylesheet_link_tag    "social_stream" %>
<%= javascript_include_tag "jquery" %>

What i think there is issue of sprockets its not working as expected please advice.

I will be really thankful to you.

like image 719
Baran Avatar asked Sep 11 '13 06:09

Baran


1 Answers

I was also having this issue but with newer versions of Rails and Ruby.

Examining the log, I was being served javascript.js from Rails cache as the server didn't see a change in the file. I went and moved the require lines around (just one) to tell Rails that there's a change in the file and re-compile/use. Wellm that did it for me!

Hope it helps somebody.

Another important finding is to upgrade your sprockets gem in your Gemfile.

I had version 2.2.1 and had issues, after upgrading to 2.2.2, it worked

gem 'sprockets', '2.2.2' 
like image 165
lsaffie Avatar answered Sep 24 '22 23:09

lsaffie