Getting SASS to work with Rails 3 - ruby-on-rails-3

I am trying to get SASS to work with Rails 3.
I have added gem 'haml' to my Gemfile (and ran bundle install) and I have added a styles.scss to my public/ directory, but it does not seem to be working. Can someone help me out? Thanks!

By default, Sass expects sass/scss files to go in public/stylesheets/sass, which are then compiled into css files in public. You can change this path by setting Sass::Plugin.options[:template_location] in your config, though.

Related

Asset pipeline won't even try to compile SASS

My setup is fairly simple default rails 3.2.1 setup. All my .css.sass files are in /app/assets/stylesheets/. I have the sass-rails '~> 3.2.3' gem in :assets group.
There's no application.css, just main.css.sass (used for main layout).
When i issue:
RAILS_ENV=production bundle exec rake assets:precompile
it compiles my coffeescripts and javascripts. There are no error messages in the log. It's like it doesn't even try to compile sass files.
The main.css.sass file header looks like this:
//=depend_on "_globals.css.sass"
#import globals
The _glocals.css.sass exists in the same directory.
James is right and it's one of the possible solutions.
The drawback of adding all files to one manifest file is that all will be precompiled to single file - which isn't always what you want.
In my case I needed separate files (one file for each layout).
Heres how to add new manifest files:
config.assets.precompile += %w( file1.css file2.css )
You don't need to have actual file1.css, if you have file1.css.sass it will be precompiled.
I think sass needs a manifest file and by default that's application.css for a rails 3.2 app. So creating application.css and //= require 'main' might dove your problem.

Unpack refinery gems in rails project

I tried rake gem:unpack but I get task not found. I would like to have refinery gems in my /vendor directory to be able to see the never ending views and partials and may be modify them.
I'm still learning how to do things the "Rails way", but I feel your need to have the files in a directory that's easy to see. One command I found that will dump in vendor in the local project is bundle install --deployment. You'll need to run this after initially doing a bundle install.
run bundle package
more here: http://gembundler.com/bundle_package.html

rails 3 sass compiling

Hello I have one question I have my file main.scss which is in public/stylesheets/scss. In documentation is written:
By default, .sass and .scss files are
placed in public/stylesheets/sass
(this can be customized with the
:template_location option). Then,
whenever necessary, they’re compiled
into corresponding CSS files in
public/stylesheets. For instance,
public/stylesheets/sass/main.scss
would be compiled to
public/stylesheets/main.css.
I have in my gemfile gem 'haml'
And from my view I do sth like this
= stylesheet_link_tag 'main'
And the file is not found when I check the source(there is a file with with information about routing error). I guess that compiling it by hand it is not way to go so how I can make compile scss file to public/stylesheets automatic? What mean in documentation that they are compiled when necessary?
Thanks in advance
Put your .sass or .scss files in public/stylesheets/sass, not public/stylesheets/scss. Then the stylesheets should automatically generate whenever you change the corresponding sass/scss file. The generated stylesheets end up in public/stylesheets/.
Renaming the folder should make it all work.
EDIT: it looks like Rails 3.1 is going to be not only including SASS by default, but it will also be moving most of the stuff found in the public folder to the app folder... so this answer will only apply to versions of rails before 3.1.

require in capistrano deploy.rb cannot find file

I have a rails 3.0.5 app and I'm setting up capistrano to use a recipe.
in my config directory I have a file named "database_capistrano.rb" and in my deploy.rb, also in config directory, I have the following line, just in the beginning:
require 'database_capistrano'
But I'm getting:
`require': no such file to load -- capistrano_database (LoadError)
Also try with:
require 'database_capistrano.rb'
And don't work...
How, in Rails 3.0.5, include files in capistrano deploy.rb??
Ok, I manage to find out how this should be done.
Just copied the file to a new sub-directory "deploy", for organization only, and at the beginning of my deploy.rb, added:
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'deploy')
Then, in deploy.rb, just used:
require 'database_capistrano'
For future visitors, I got better results with the answer found in Capistrano: deploy.rb file refactoring
i.e instead of require, use load. As long as that file is a gem in the bundle or a file that requires other gems that are in bundle, this will work.
To be frank, I didn't try the accepted answer, half because it looked a little workaround-ish, and half because I didnt fully understand how to adapt it for my situation

Automatic SASS to CSS in RoR 3 without sass --watch

I've read all topics re. SASS + RoR, but there are no answers for my small question. I'm running Rails 3 and using alternate syntax, without SCSS. Haml gem included in the project. What else should I configure to have autogenerated css files without "sass --watch"?
Thanks in advance!
You just need to put gem "haml" in your Gemfile, then put your Sass files in public/stylesheets/sass.