Skip to content

Commit

Permalink
Support Rails 4.2 even though I won't advertise it
Browse files Browse the repository at this point in the history
I was thinking of making two releases, but I'll keep this one Rails 4.2
compatible. However, I won't support Ruby 1.9.3.
  • Loading branch information
gsamokovarov committed Dec 13, 2015
1 parent 36b82ef commit 63e139d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/web_console/extensions.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
ActionDispatch::DebugExceptions.class_eval do
def render_exception_with_web_console(request, exception)
render_exception_without_web_console(request, exception).tap do
backtrace_cleaner = request.env['action_dispatch.backtrace_cleaner']
# Retain superficial Rails 4.2 compatibility.
env = Hash === request ? request : request.env

backtrace_cleaner = env['action_dispatch.backtrace_cleaner']
error = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).exception

# Get the original exception if ExceptionWrapper decides to follow it.
request.env['web_console.exception'] = error
env['web_console.exception'] = error

# ActionView::Template::Error bypass ExceptionWrapper original
# exception following. The backtrace in the view is generated from
# reaching out to original_exception in the view.
if error.is_a?(ActionView::Template::Error)
request.env['web_console.exception'] = error.original_exception
env['web_console.exception'] = error.original_exception
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion web-console.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 2.2.2'

rails_version = ">= 4.0"
rails_version = ">= 4.2"

s.add_dependency "railties", rails_version
s.add_dependency "activemodel", rails_version
Expand Down

0 comments on commit 63e139d

Please sign in to comment.