vendredi 11 août 2017

Ruby on Rails CSS not loading via assets pipeline

I have searched the web for a solution to this problem and haven't found a solution that works albeit I did find similar problems.

So, I am new to RoR development and this is my first app. I am try to create a page and have so far managed to route to my first page using a controller with an action. The routing works fine.

The problem is with the CSS, I have placed the css in a separate .css file within assets/stylesheets/main.css.

Here it is:

h1 {
   font-size: 100px;
}

I link to all stylesheets using the default method provided by Rails, it is placed in my application.html.erb file like so:

.
.
.
    <%= csrf_meta_tags %>
    <%= stylesheet_link_tag 'default', media: 'all', 'data-turbolinks-track': 'reload' %>
.
.
.

From my research, I have learnt that the assets pipeline allows you to place all of your CSS in the assets/stylesheet directory (and JS in the JS directory etc.). Rails should then use these CSS files automatically.

But this isn't working for me as the index.html.erb file stays the same as it would without the main.css when I run the app.

Any help would be appreciated.

Let me know if you require further information.

Thank you.

P.S. Using Rails 5.0.5 and ruby 2.2.6p396 (2016-11-15 revision 56800) [i386-mingw32] on Windows 10

Aucun commentaire:

Enregistrer un commentaire