Search code examples
cssruby-on-railsruby-on-rails-4asset-pipelineslim-lang

Assets loaded but not applied in rails 4


I've just created a test project and been reading about the assets pipeline. So far, the assets are being loaded but not applied, as if I go to localhost:3000/assets/application.css I see the style I've written but I don't see the rules applied to the DOM.

Rails version: 4.2.1 Ruby version: 2.2.0

The structure is the following:

app
--- assets
------ images
------ javascripts
------ stylesheets
------------ application.css
------------ todos.css

The content of application.css is the following:

/*
*= require_tree .
*= require_self
*/

The content of application.js the following:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

The rails APP is very simple, as it's just a model (todo.rb), the controller for that model (todos_controller.rb) with the following content:

class TodosController < ActionController::Base
  def index
    @todos = Todo.all
  end
end

Very simple, and for the view I'm using Slim templates with the following hierarchy:

app
--- views
------ todos
--------- index.slim

The content of application.html.erb is the following:

<!DOCTYPE html>
<html>
<head>
  <title>Test</title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
</head>
<body>

<%= yield %>

</body>
</html>

And for the view:

.todos
  - @todos.each do |todo|
    .title = todo.title
    .content = todo.content

Is there about the assets pipeline I'm missing? Thanks in advance.


Solution

  • Rename index.slim into index.html.slim.

    P.S. convention over configuration