Created
November 6, 2011 20:13
-
-
Save mjtko/1343402 to your computer and use it in GitHub Desktop.
Initializer to monkey patch in https://github.com/rails/sass-rails/pull/70 before it's accepted upstream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sass/rails/importer' | |
if defined?(Sass::Rails::VERSION) && Sass::Rails::VERSION[0..3] >= '3.1.' | |
Rails.logger.warn ' == MONKEY == Patching sass-rails: https://github.com/rails/sass-rails/pull/70' | |
Rails.logger.warn " == MONKEY == Please remove #{__FILE__} once Sass::Rails upstream has pulled in the fix" | |
# monkey patch to incorporate https://github.com/rails/sass-rails/pull/70 | |
module Sass | |
module Rails | |
class Importer | |
def resolve(name, base_pathname = nil) | |
name = Pathname.new(name) | |
if base_pathname && base_pathname.to_s.size > 0 | |
root = context.pathname.dirname | |
name = base_pathname.relative_path_from(root).join(name) | |
end | |
partial_name = name.dirname.join("_#{name.basename}") | |
@resolver.resolve(name) || @resolver.resolve(partial_name) | |
end | |
end | |
end | |
end | |
end |
Updated so as not to fall over when Sass::Rails doesn't exist - such as when the app is operating under the production environment!
Updated == '3.1.'
to >= '3.1.'
as this is still borked in Rails 3.2.0. :-/
Was able to get this working in Rails 3.2.1
Hi
Thanks for this monkey-patch.
I have an issue getting it to work when I user the rake task "assets:precompile". This seems to be an issue due to some changes introduced in Rails 3.1.1. Is there someway or somewhere else I can include this monkey patch to ensure that it is called when running the precompile task ?
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This monkey patch initializer made available to work round issues such as: thoughtbot/bourbon#26 (comment)
Stick it in #{Rails.root}/config/initializers and your SASS relative path import woes should disappear!
Enjoy. :)