From 0a35cff21f4d654ba5a5d2296234a819a0192ceb Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 10 Jun 2010 13:31:48 -0700 Subject: [PATCH] Hackily fix the Rails 3 routing errors we were seeing in 3.0.11. Closes gh-194 --- doc-src/HAML_CHANGELOG.md | 8 ++++++++ doc-src/SASS_CHANGELOG.md | 8 ++++++++ lib/sass/plugin/rails.rb | 13 +++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/doc-src/HAML_CHANGELOG.md b/doc-src/HAML_CHANGELOG.md index 2f33df00..18a99398 100644 --- a/doc-src/HAML_CHANGELOG.md +++ b/doc-src/HAML_CHANGELOG.md @@ -3,6 +3,14 @@ * Table of contents {:toc} +## 3.0.12 (Unreleased) + +## Rails 3 Support + +Apparently the last version broke in new and exciting ways under Rails 3, +due to the inconsistent load order caused by certain combinations of gems. +3.0.12 hacks around that inconsistency, and *should* be fully Rails 3-compatible. + ## 3.0.11 [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.11). diff --git a/doc-src/SASS_CHANGELOG.md b/doc-src/SASS_CHANGELOG.md index 80e40bb7..e939d7b8 100644 --- a/doc-src/SASS_CHANGELOG.md +++ b/doc-src/SASS_CHANGELOG.md @@ -3,6 +3,14 @@ * Table of contents {:toc} +## 3.0.12 (Unreleased) + +## Rails 3 Support + +Apparently the last version broke in new and exciting ways under Rails 3, +due to the inconsistent load order caused by certain combinations of gems. +3.0.12 hacks around that inconsistency, and *should* be fully Rails 3-compatible. + ## 3.0.11 [Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.11). diff --git a/lib/sass/plugin/rails.rb b/lib/sass/plugin/rails.rb index c819208e..acc91e5f 100644 --- a/lib/sass/plugin/rails.rb +++ b/lib/sass/plugin/rails.rb @@ -12,8 +12,17 @@ unless defined?(Sass::RAILS_LOADED) if defined?(ActionController::Metal) # Rails >= 3.0 require 'sass/plugin/rack' - Rails.application.instance_variable_set('@app', - Sass::Plugin::Rack.new(Rails.application.app)) + if Rails.application.instance_variable_get('@app') + # The application has already been built, + # so we need to hack the middleware in + Rails.application.instance_variable_set('@app', + Sass::Plugin::Rack.new(Rails.application.app)) + else + # The application hasn't been built yet, + # so we can just add Sass::Plugin::Rack + # to the pending middleware stack. + Rails.configuration.middleware.use(Sass::Plugin::Rack) + end elsif defined?(ActionController::Dispatcher) && defined?(ActionController::Dispatcher.middleware) # Rails >= 2.3