I want to style a static page to be as a landing page for the rails app. The static page is from the StaticPagesController. But the problem is when I add the class in the static page (home.html.erb) and in the application.css add the styling it doesn't use the styles. Any suggestions?
-
What layout are you using? (check for app/views/layouts) usually it's application.html.erb – siegy22 Jul 29 '16 at 20:53
2 Answers
Rename the application.css
to application.scss
because for rails 4 is better to work with .scss
extension.
Then, DON'T write your code directly in your application.scss
file, is a really bad practice.
Import your .scss
files (without the extension) For example:
*= require_tree .
= require rails_bootstrap_forms
*= require_self
*/
@import "yourfilename";
If you are using .sass
extension, then you must include this line in your config/application.rb
file:
config.sass.preferred_syntax = :sass
This is because rails takes by default .css or .scss extension instead of .sass extension.
If you deleted the content of the application.scss
you have to restore it too.

- 184
- 8
-
Yes, actually is like a Must. Application takes every single stylesheets. But your issue is different. You are using .sass extension. In your application.rb file add this line: config.sass.preferred_syntax = :sass Rails use by default .css or .scss not .sass extension – Carlos Orellana Jul 29 '16 at 21:20
This should be the file. \app\views\layouts\application.html.erb
You can add link to your stylesheet in the head section.
or
You can @include
your custom css file into application.css
file which should be located at \app\assets\stylesheets\

- 55
- 11