7

I felt strange that why the style not loaded,

So I wrote wrong content intentionally on application.css.scss,

And precompile and load the page didn't give me any error.

I thought the application.css.scss file must not be loaded and compiled.

Unfortunately, it seems no to be.

application.css.scss

@i2dmport "compass";

/*
 * 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 jquery.fileupload-ui
 *= require dropzone/dropzone
 *= require dropzone/basicdew
 *= require_tree .
 */

@import "layout";

application.rb

config.autoload_paths += %W(#{Rails.root}/app/pdfs)
config.autoload_paths += %W(#{config.root}/lib/)

# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
config.assets.paths << "#{Rails.root}/vendor/themes"

Gemfile (I not sure if there any conflict)

source 'http://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.5'

# Use postgresql as the database for Active Record
gem 'pg', '~> 0.17.1'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

gem "bootstrap-sass", "~> 3.1.1"
gem "compass-rails"
gem "therubyracer"
gem "execjs"
gem "hirb-unicode"
gem "devise", "~> 3.3.0"
gem "devise_ldap_authenticatable", "~> 0.6.1"
gem "net-ldap"

gem "will_paginate", "~> 3.0"
gem "rspec"
gem "awesome_print", require: "ap"
gem "tinymce-rails"
gem "simple_form"
gem "haml-rails"
gem "taps"
gem "analytics-ruby"
gem "bcrypt-ruby"
gem "bourbon"
gem 'cancancan', '~> 1.8'

gem "sunspot_rails"
gem "sunspot_solr"

gem "simple-navigation"
gem "simple-navigation-bootstrap"


#fast command
gem "spring", group: :development


#Handy tools for active record
gem "squeel", "~> 1.2.1"  # Last officially released gem
# gem "squeel", :git => "git://github.com/activerecord-hackery/squeel.git" # Track git repo
gem 'prawn'
gem 'rb-readline', "~> 0.5.0.pre.1"

gem 'chartkick'

gem 'rails-erd', :group => :development
gem 'quiet_assets', group: :development

gem 'curb'
gem 'rest_client'

# only for assets not required in production mode
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery.fileupload-rails', "~> 1.10.0"
gem 'twitter-bootstrap-rails'
group :development do
  gem "faker"
  gem "rspec-rails"
  gem "guard-rspec"
  gem "pry"
  gem "pry-remote"
  gem "pry-nav"
  gem 'pry-rescue'
  gem 'pry-stack_explorer'
end

gem "paperclip", "~> 4.1"
gem 'dropzonejs-rails'

layout

!!!
%html
  %head
    = stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true
    = stylesheet_link_tag params[:controller]
    = javascript_include_tag "application", "data-turbolinks-track" => true
    = javascript_include_tag params[:controller], "data-turbolinks-track" => true
Cœur
  • 37,241
  • 25
  • 195
  • 267
newBike
  • 14,385
  • 29
  • 109
  • 192
  • `@i2dmport "compass";` Is it a typo or its just something I am not aware of? – manu29.d Sep 11 '14 at 07:41
  • I was intentionally to typo it. to ensure the file didn't be loaded – newBike Sep 11 '14 at 07:49
  • He did it as a test I presume – Richard Peck Sep 11 '14 at 07:51
  • You've got a `themes` folder you're trying to include. May I ask where your `application.css.scss` is stored? Is it in the standard `app/assets/stylesheets/` location? – Richard Peck Sep 11 '14 at 07:53
  • @RichPeck yes , under `app/assets/stylesheets` – newBike Sep 11 '14 at 08:12
  • okay. Can you try removing the references to your `theme` stylesheets from your `config` and any of the assets you have? It may be causing a problem with Rails itself (which Sprockets won't be able to be alerted to - thus preventing the precompilation process from proceeding) – Richard Peck Sep 11 '14 at 08:18
  • is this for production or development? did you precompile in the correct environment, namely, `RAILS_ENV=production rake assets:precompile` for production environment? – ahnbizcad Sep 13 '14 at 07:47
  • Could you please update your question with a listing of the spreadsheets that were loaded? If you run in dev it won't consolidate the files for you, but it *will* pre-compile the SASS ones. – Rich Seviora Jan 08 '15 at 21:07

4 Answers4

1

i had this exact same problem and was driving me crazy. i had a app/assets/stylesheets/mycustom_stylesheet.css.scss with the styles that loaded fine in development but when i deployed to production on heroku, none of my styles appeared. i solved it by placing the file custom.css in my vendor/assets/stylesheets directory with this content:

/*
 *= require mycustom_stylesheet
*/

i also added this line to my initializers/assets.rb file although i'm not sure its necessary.

Rails.application.config.assets.precompile += %w( mycustom_stylesheet.css )
radamnyc
  • 157
  • 1
  • 11
0

May be you have an "application.css" file inside of your "/vendor/themes/" or "/lib" folder ?

What happens if you remove this line "config.assets.paths << "#{Rails.root}/vendor/themes" from your application.rb file?

alvaritono
  • 121
  • 3
0

Try running below command

RAILS_ENV=production rake assets:precompile

or

RAILS_ENV=development rake assets:precompile
Love-Kesh
  • 777
  • 7
  • 17
  • Warning - make a backup copy first on development. This will create a bunch of files you don't want/need in your git. – JosephK Apr 26 '16 at 13:29
0

Today I came across a similar problem that changes in application.css.scss does not update in page styling. Later I found out that is because there is an error in my .scss file, ul being misspelled as u1. After the error is fixed, the styling finally updates in page refreshes, with no need to restart rails server.

Sophia Feng
  • 993
  • 11
  • 16