Skip to content

Commit

Permalink
Merge pull request #6 from ghiculescu/master
Browse files Browse the repository at this point in the history
Better error logging
  • Loading branch information
daveallie authored Nov 26, 2020
2 parents f96e1e9 + 4a7cf17 commit 471b5cf
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions lib/rails-route-checker/loaded_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@
module RailsRouteChecker
class LoadedApp
def initialize
@app = suppress_output do
app_base_path = Dir.pwd
app_base_path = Dir.pwd
suppress_output do
require_relative "#{app_base_path}/config/boot"
require_relative "#{Dir.pwd}/config/environment"
end

a = Rails.application
a.eager_load!
begin
suppress_output do
require_relative "#{Dir.pwd}/config/environment"
end
rescue Exception => e
puts "Requiring your config/environment.rb file failed."
puts "This means that something raised while trying to start Rails."
puts ""
puts e.backtrace
raise(e)
end

suppress_output do
@app = Rails.application
@app.eager_load!
attempt_to_load_default_controllers
a.reload_routes!
@app.reload_routes!
Rails::Engine.subclasses.each(&:eager_load!)

a
end
end

Expand All @@ -25,7 +36,7 @@ def routes
reject_route?(r)
end.uniq

return @routes unless @app.config.respond_to?(:assets)
return @routes unless app.config.respond_to?(:assets)

use_spec = defined?(ActionDispatch::Journey::Route) || defined?(Journey::Route)
@routes.reject do |route|
Expand Down

0 comments on commit 471b5cf

Please sign in to comment.