Generates a css file from the new sass (scss) format using sinatra and haml

I am writing a sinatra application with haml and sass. When I try to bind in the stylesheet with the scss extension located in my views folder, I get the following error: NoMethodError in /nav.css undefined `scss' method

Here is my get method

get '/nav.css' do content_type 'text/css', :charset => 'utf-8' scss :nav end 

I just got this to work when I switch to the older sass syntax. I also have to change nav.scss to nav.sass and the get to sass: nav method

I also tried just with sass: nav with nav.scss and sass: nav with nav.sass, but still with scss syntax

+6
ruby sass sinatra haml
source share
2 answers

Excerpt from Sinatra README

 ## You'll need to require haml or sass in your app require 'sass' get '/stylesheet.css' do scss :stylesheet end 

Do you need a sass stone?

What version of Sinatra are you using. scss support was added in 2010.09.01 (the version of the same day was increased from 1.0 to 1.1), maybe you need to update.

+2
source share

I do not use the above code from README, just add the following to the app.rb file after updating your gem.

 get '/stylesheets/:name.css' do content_type 'text/css', :charset => 'utf-8' scss(:"stylesheets/#{params[:name]}") end 

Reboot the server and everything is configured. Happy Scssing.

+13
source share

All Articles