Created
September 27, 2014 07:14
-
-
Save BenMorganIO/0c55638993b08bc74383 to your computer and use it in GitHub Desktop.
Dart2JS Rails Caching Issue
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
| # For some reason you have to delete the cache beforehand | |
| # when you use the dart2js gem with Rails. | |
| # Just add this before_action in your controller and you're | |
| # good | |
| class ApplicationController < ActionController::Base | |
| before_action :remove_old_dart_files | |
| protect_from_forgery with: :exception | |
| private | |
| def remove_old_dart_files | |
| files = Dir["#{Rails.root}/tmp/cache/assets/dart2js*"] | |
| dart_app_mtime = File.mtime("#{Rails.root}/app/assets/dart/dart_app.dart") | |
| files.each do |file| | |
| File.delete(file) if File.mtime(file) < dart_app_mtime | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment