Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/compass-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ def sass_config
end

def sprockets
@sprockets ||= ::Rails.application.assets
@sprockets ||= ::Rails.application.assets || ::Rails.application.config.assets
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails.application.assets and Rails.application.config.assets are completely different things. They are not mutually interchangeable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, however, they both respond to paths. Nevermind, I think @timhaines took a better approach at fixing this issue in #263.

end

def context
@context ||= begin
sprockets.version = ::Rails.env + "-#{sprockets.version}"
setup_fake_rails_env_paths(sprockets)
context = ::Rails.application.assets.context_class
context = sprockets.context_class
context.extend(::Sprockets::Helpers::IsolatedHelper)
context.extend(::Sprockets::Helpers::RailsHelper)
context.extend(::Sass::Rails::Railtie::SassContext)
Expand Down
22 changes: 17 additions & 5 deletions lib/compass-rails/patches/compass.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
private

def image_path_for_size(image_file)
begin
file = ::Rails.application.assets.find_asset(image_file)
return file
rescue ::Sprockets::FileOutsidePaths
return super(image_file)
if ::Rails.application.config.assets.compile
begin
file = CompassRails.sprockets.find_asset(image_file)
return file.respond_to?(:pathname) ? file.pathname.to_s : file
rescue ::Sprockets::FileOutsidePaths
return super(image_file)
end
else
return image_file if File.exists?(image_file)

assets_manifest = ::Rails.application.assets_manifest
file = assets_manifest.assets[image_file]
if file
::Rails.root.join("public", assets_manifest.directory, file)
else
super(image_file)
end
end
end
end
4 changes: 2 additions & 2 deletions lib/compass-rails/patches/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ def sass_options
@sass_options[:custom] = {:resolver => ::Sass::Rails::Resolver.new(CompassRails.context)}
@sass_options[:load_paths] ||= []
unless @sass_options[:load_paths].any? {|k| k.is_a?(::Sass::Rails::Importer) }
::Rails.application.assets.paths.each do |path|
CompassRails.sprockets.paths.each do |path|
next unless path.to_s =~ STYLESHEET
Dir["#{path}/**/*"].each do |pathname|
# args are: sprockets environment, the logical_path ex. 'stylesheets', and the full path name for the render
context = ::CompassRails.context.new(::Rails.application.assets, File.basename(path), Pathname.new(pathname))
context = ::CompassRails.context.new(CompassRails.sprockets, File.basename(path), Pathname.new(pathname))
@sass_options[:load_paths] << ::Sass::Rails::Importer.new(context)
end
end
Expand Down