Charles
Charles

Reputation: 11786

Rails 4.2 is serving stylesheets twice in development mode

I'm started a new project:

rails new test-styles
cd test-styles
rails generate controller CreditCards open
rails server

This is the produced HML

<link rel="stylesheet" media="all" href="/assets/credit_cards-1ed56f25de9e08bdac6a0e4c565de8ec.css?body=1" data-turbolinks-track="true" />
<link rel="stylesheet" media="all" href="/assets/application-5760c24f7be45363d79a66235e9d6b39.css?body=1" data-turbolinks-track="true" />

And Here the content of each css:

application.css

/* line 4, /.../test-styles/app/assets/stylesheets/credit_cards.scss */
body {
  background: red;
}

credit_card.css

/* line 4, /.../test-styles/app/assets/stylesheets/credit_cards.scss */
body {
  background: red;
}

As we can see application.css is included credit_cards so why is credit_cards also included in the page?

This is very annoying because I would like to use the gem twitter-bootstrap-rails and also less variables. Of course if credit_cards is compile alone, it will fail...

I'm new to RoR, maybe I messed something...

Upvotes: 0

Views: 227

Answers (1)

PatNowak
PatNowak

Reputation: 5812

You paste it wrong... Rails's application css has lines:

*= require_tree .
*= require_self
*/

These lines use all css files in directory assets/stylesheets of your application. More information about it is here.

Upvotes: 1

Related Questions