Skip to content

Instantly share code, notes, and snippets.

@Lordnibbler
Last active December 19, 2015 15:58
Show Gist options
  • Select an option

  • Save Lordnibbler/5979822 to your computer and use it in GitHub Desktop.

Select an option

Save Lordnibbler/5979822 to your computer and use it in GitHub Desktop.
# we need to protect against multiple includes of the Rails environment (trust me)
require './config/environment' if !defined?(Rails) || !Rails.initialized?
require 'sprockets'
require 'sprockets-helpers'
require "sprockets-sass"
require "sass"
unless Rails.env.production?
map '/assets' do
sprockets = Sprockets::Environment.new
sprockets.append_path 'app/assets/images'
sprockets.append_path 'app/assets/javascripts'
sprockets.append_path 'app/assets/stylesheets'
sprockets.append_path 'lib/assets/images'
sprockets.append_path 'lib/assets/javascripts'
sprockets.append_path 'lib/assets/stylesheets'
sprockets.append_path 'vendor/assets/images'
sprockets.append_path 'vendor/assets/javascripts'
sprockets.append_path 'vendor/assets/stylesheets'
sprockets.context_class.class_eval do
# i can access it here
# throws error:
# /Users/meowingtons/Code/onelogin/onelogin.com/lib/authenticated_system.rb:102:in `send': undefined method `helper_method' for #<Class:0x10edad978> (NoMethodError)
# from /Users/meowingtons/Code/onelogin/onelogin.com/lib/authenticated_system.rb:102
include AuthenticatedSystem
end
Sprockets::Helpers.configure do |config|
config.environment = sprockets
config.prefix = '/assets'
config.digest = false
config.debug = true
end
run sprockets
end
end
map '/' do
use Rails::Rack::LogTailer unless Rails.env.test? || Rails.env.development?
use Rails::Rack::Debugger unless Rails.env.test? || Rails.env.development?
use Rails::Rack::Static
run ActionController::Dispatcher.new
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment