Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix Issue 19 #22

Open
wants to merge 1 commit into from

2 participants

@iggant

...rd-rails-assets in the production mode

In the production Rails.application.assets is Sprockets::Index but in the development it is Sprockets::Environment,

Class Index doesn't allow to expire its index, so we have to have some work around it.
So I evaluate code which access directly to the cache

@dnagir
Owner

I don't fee good about checking the rails environment against production. There must be other ways of doing that.

Unfortunately I'm not using guard-rails-assets anymore and won't be able to dig into it.

Do you want to take over the maintenance of this gem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 13, 2012
  1. @iggant

    Fix Issue #19 TypeError: can't modify immutable index when starting g…

    iggant authored
    …uard-rails-assets in the production mode
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 2 deletions.
  1. +17 −2 lib/guard/rails-assets/rails_runner.rb
View
19 lib/guard/rails-assets/rails_runner.rb
@@ -68,7 +68,7 @@ def precompile
config.assets.precompile,
:manifest_path => config.assets.manifest,
:digest => config.assets.digest,
- :manifest => config.assets.digest.nil?)
+ :manifest => @@digest.nil?)
compiler.compile
end
@@ -81,14 +81,29 @@ def compile_assets
return false unless @@rails_booted
begin
clean
+ expire_cache_index
precompile
true
rescue => e
puts "An error occurred compiling assets: #{e}"
false
- ensure
+ end
+ end
+
+ def expire_cache_index
+ if ENV['RAILS_ENV'] == "production"
+ ::Rails.application.assets.instance_eval do
+ # Empty Cache Index
+ @assets = {}
+ # Clear cache upstream in Environment
+ @environment.instance_eval do
+ @assets = {}
+ end
+ end
+ else
::Rails.application.assets.instance_eval { expire_index! }
end
end
+
end
end
Something went wrong with that request. Please try again.