Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

application.css.scss not compiled on Rails 4

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
like image 930
newBike Avatar asked Sep 11 '14 07:09

newBike


1 Answers

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 )
like image 116
radamnyc Avatar answered Nov 17 '22 17:11

radamnyc