Try using Stylus in your Rails application

I am trying to install and use Stylus in a new rails app.

First, I created a new rails app: rails new try-stylus

Then I ran the command: sudo npm install stylus

And I added gem 'stylus'

to mine Gemfile

and ran bundle

to install it.

At application.rb

the end of the class, Application < Rails::Application

I added:

if defined? 
   Stylus.debug = Rails.env != "production"
end

      

I renamed application.css

to application.styl

and edited its content:

//= require_tree .
//= require_self

body
  background red

      

I created a simple one PageController

with an action index

displaying the Hello world template index.html.erb

.

In the end, I ran rails s

.

And got the following error in my browser:

Displaying /.../ app / views / layouts / application.html.erb where line # 5 is raised: ExecJS :: ProgramError in Pages index # TypeError: undefined is not a function

Where line 5: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>

Do you have any hints?

+3


source to share





All Articles