I am building a Rails application and I am in front of a weird issue in production: when capistrano compile assets Rails want to create a css version of all partials I included in application.sass and it breaks the deploy because of the variables and mixins I used in this partials.
In my application.sass:
#import compass
#import header // _header.sass file
#import footer // _footer.sass file
#import content // _content.sass file
...
I don't understand why because in another project I don't have this problem.
Here is my assets.rb file:
Rails.application.config.assets.version = '1.2'
Rails.application.config.assets.precompile += %w( email.css newsletter.css maintenance.css noscript.css )
Does anyone knows how can I tell Rails to not compile all partials in css files ?
Thanks for your help !
My application:
- gem 'rails', '4.2.5'
- gem 'sass-rails', '~> 5.0'
- gem 'compass-rails', github: 'Compass/compass-rails', branch: 'master'
- gem 'capistrano', '~> 3.1'
- gem 'spring', '~> 1.3.4'
After spending hours and hours on all the web, I finally discovered the guilty: Froala gem
By looking to the source of the plugin, and the list of precompiled assets, they have a folder called 'plugins' which has the same name as a personal folder. This was meaning my plugins folder with sass partials was also compiled ! The way to fix it was to rename my own 'plugin' folder.
Related
I'm using bootstrap-sass gem in my Rails project with version 2.3.1.0. However, when pushed up to Heroku, I'm getting the Bootstrap 3 styles. I inspect the CSS style and it indeed does say Bootstrap version 3.
On local, the assignment seems to be correct. But equally perplexing, when I inspect the CSS file, it says Bootstrap version 3 despite displaying what looks like the Bootstrap 2.3 styles.
I think at one point, my bootstrap-sass gem was using the Bootstrap 3, but when I put it back to gem 'bootstrap-sass', '2.3.1.0', I'm getting this strange conflict. I really just want my Heroku app to display the styles correctly. Even though I'm pushing up my current local version to Heroku, it is still using Bootstrap 3 stylings.
Here's what I've got:
Gemfile:
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'bootstrap-sass', '2.3.1.0'
end
I've created a styles.css.scss file, where I have the line #import "bootstrap";Here's what it looks like on localhost:
Here's what it looks like on Heroku:
It sounds like your Gemfile.lock might be incorrect. Have you verified that the correct version of the bootstrap gem is defined in Gemfile.lock?
Also might be worth just checking nothing is set in the Heroku env variable BUNDLE_WITHOUT. See the Heroku gem docs.
Not sure why this worked, but I found the second answer here to work for me.
I added *= require bootstrap" right above " *= require_tree . in application.css.
Then ran "bundle install --without production", followed by "rake assets:precompile". Committed the changes to git and then pushed to heroku.
I've never had to specifically require bootstrap in the asset pipeline before, but it works!
I have a simple rails project (ruby 1.9.3, rails 3.2.13), and I am attempting to incorporate the Gumby CSS Framework. The framework requires Compass, with modular-scale.
For sake of completeness the majority of the post contains information, skip to the end for the actual problem.
The working directory is being watched with
$ compass watch`
Compass was incorporated into the project with:
compass create --app rails \
-l ./app/assets/stylesheets/gumby/ \
--using modular-scale
The contents of config/compass.rb is:
require 'modular-scale'
project_type = :rails
And the location of Gumby source (SCSS) is app/assets/stylesheets/gumby.
The resulting compiled css appears in public/assets/gumby/gumby.css.
The following is within my Gemfile
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'compass-rails'
gem 'coffee-rails', '~> 3.2.1'
gem 'modular-scale'
gem 'gumby-rails'
gem 'uglifier', '>= 1.0.3'
end
And bundle install completes without errors.
However...
The following error message appears on all served pages:
Sass::SyntaxError in Users#index
Showing PROJECT_ROOT/app/views/layouts/application.html.erb where line #5 raised:
File to import not found or unreadable: compass/typography/vertical_rhythm.
Load path: Sass::Rails::Importer(PROJECT_ROOT/app/assets/stylesheets/gumby/_base.scss)
(in PROJECT_ROOTr/app/assets/stylesheets/gumby/_base.scss)
After hours of tinkering, I am at a loss as to the reason why Sass cannot read the Compass library.
I believe I found the solution from https://stackoverflow.com/a/9021785/1280997.
Removing config/compass.rb and rebooting the server fixes the immediate problem, however I am now faced with:
Undefined mixin 'box-sizing'.
(in PROJECT_ROOT/app/assets/stylesheets/gumby/_base.scss)
Ok, after much digging, I've found a way to incorporate Gumby into Rails, however I've lost the ability to edit the scss in the process. I did this using the gumby-framework gem. Setup was simple, following the README.
I am in the process of upgrading an old app to the asset pipline but after following the ryan bates tutorial on upgrading to 3.1 I am still not able to take advantage of the pipline. In order to rule out my upgrade process I created a fresh rails app and attempted some coffee scripting and adding other files to the /assets/javascripts folder, however any additional files besides the application.js do not seem to be rendered.
This is my application.js file:
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
alert("this displays fine");
And the additional dogs.js.coffee file:
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
alert "cant see this!"
It seems to be a sprockets issue but I really cant find anyone with the same problem, or info on when additional javascript files within the assets folder are not included in the application.js via the require_tree .
Here is my gem file:
gem 'rails', '3.1.1'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
my ruby version is 2.0.0p195
thanks for any help!
G
It seems the ruby version was my problem, I downgraded to ruby 1.9.3, then reinstalled gems and it works now!
When using rails new, the following gems are automatically included in a Gemfile:
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
I'm not a huge fan of SASS, and I strongly dislike Coffeescript, and it's getting annoying having .scss and .js.coffee files in every new project.
How can I remove these gems from rails new so that they won't be included by default in every new project?
Thanks for any responses in advance.
To answer your question: You can always create your own template.rb and pass that into rails new using the --template or -m option. RailsWizard will even generate a template for you.
Let me also say that the default template doesn't generates any .scss or .coffee files, but it is a little annoying that the gems are bundled automatically. Mostly, though, you could ignore that they're installed--just remove those two lines from your Gemfile.
I've got 3.1 application.
At the beginning i'd added
config.assets.enabled = false
not to use pipeline.
Now i've commented this line. restart server.
I've got app\assets\javascripts\application.js
In my layout view I use:
<%= javascript_include_tag "application" %>
my page tries to load "javascripts/application.js" not assets/application.js
What may be wrong in my configuration?
gemfile (unnecessary removed):
gem 'rails', '3.1.1'
gem 'sqlite3'
# Asset template engines
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Rather than commenting out the line, have you tried leaving it in and making it config.assets.enabled = true instead? It looks like the default value will always be false, so you need to explicitly set it to true.
If you turn the pipeline off then the Rails helpers revert to the old paths to javascript and CSS - in those folders in the /public directory. If you don't want to use the pipeline then you have to use those folders instead, not the assets folder ones.
Dylan is correct - you have to explicitly enable the pipeline, and this is the default for a new generated app.