Reputation: 12873
I am currently working witn Rails 3.1. I need to use only one css file but the problem is that when I add the
<link href="http://mydomain.net/assets/some.css"></link>
it doesn't exist. I need to get the css files from that particular css file and no other css files should be loaded.
How do I do that in Rails 3.1?
Update:
Adding this to production.rb:
config.assets.precompile += ['some.css']
causes the following error:
** [out :: domain.net] rake aborted!
** [out :: domain.net] stack level too deep
** [out :: domain.net] (in /home/deployer/apps/domain/releases/20120410204601/app/assets/stylesheets/some.css.scss)
** [out :: domain.net]
** [out :: domain.net] Tasks: TOP => assets:precompile:primary
** [out :: domain.net] (See full trace by running task with --trace)
Update #2:
the filename for some.css is actually some.css.scss.
Update #3:
I just discovered the problem and it is caused by this:
https://github.com/rails/sass-rails/issues/78
Upvotes: 2
Views: 2261
Reputation: 5729
As you are in production environment, all your assets must be precompiled, i.e. turned into static files and copied to /public
.
In production all your individual files in app/assets
are not directly accessible because they are not precompiled. Your individual css files are not precompiled when you run
rake assets:precompile
According to the asset pipeline documentation:
If you have other manifests or individual stylesheets and JavaScript files to include, you can add them to the precompile array:
So for you, add a manifest header at the top of your css file:
/*
*= require_self
*/
And then add in your config:
config.assets.precompile += ['some.css']
Then precompile your assets and access your css file as usual:
<%= stylesheet_link_tag 'some' %>
Edit by @Thorpe Obazee
The answer is essentially correct if only sass-rails 3.1.5 didn't have any issues. So I accepted the answer.
https://github.com/rails/sass-rails/issues/78
Upvotes: 7
Reputation: 111
You need to add your stylesheet to your assets folder. Then use
<%= stylesheet_link_tag "some", :media => "all" %>
to load your stylesheet.
Upvotes: 0