Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Delegation failed : Sinatra embedded in Rails app with Sass #245

Closed
guillaumerose opened this Issue · 2 comments

3 participants

@guillaumerose

When Sinatra is embedded in Rails, there is some issue with delegate and Sass. Developers from Sass report that as a Sinatra bug.

https://github.com/nex3/haml/issues/360

Trace

(__DELEGATE__):2:in `options'
(__DELEGATE__):2:in `send'
(__DELEGATE__):2:in `options'
sass (3.1.0.alpha.253) lib/sass/./sass/plugin.rb:80:in `update_stylesheets'
sass (3.1.0.alpha.253) lib/sass/./sass/plugin.rb:54:in `check_for_updates'
sass (3.1.0.alpha.253) lib/sass/./sass/plugin/rack.rb:51:in `call'

Issue from Sass

If trying to integrate Sinatra through Rack into your Rails 3 app, it will throw a wrong number of arguments error (0 for 1). This is because Sinatra overwrites (or delegates) the options variable. The bug occurs in the Sass::Plugin module:

def update_stylesheets(individual_files = [])
  return if options[:never_update]
  compiler.update_stylesheets(individual_files)
end

A quick fix is to scope the options hash using Sass::Plugin.options:

def update_stylesheets(individual_files = [])
  return if Sass::Plugin.options[:never_update]
  compiler.update_stylesheets(individual_files)
end

This worked for me so I could move forward. Hope this helps anyone else.

@bensie

I'm having the same issue.

@rkh
Owner

Yes, this is caused by Sinatra, but what should we do? This is by design. The Sinatra delegator (activated by require 'sinatra') defines Object#options. One possible solution would be to call super if no argument/block is given, but that is kinda hackish. I will give this some thought.

@rkh rkh was assigned
@rkh rkh closed this in 53b5ccd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.