richpeck/exception_handler

@exception.status == "500" is always false (even during a 500 error)

adamtLICOR opened this issue · 4 comments

This is probably due to something I've set up in my application (newish to Rails, and Rails 5 doubly so), but:

None of the logic contained within the div tag on the show page ever triggers, as
if @exception.status == "500" is always false.

(Here is the div tag for reference):

<%= content_tag :div, class: "exception", data: { status: @exception.status, response: @exception.response.to_s.humanize, rails: Rails.version }, onclick: ("location.href=\"#{root_url}\";" if @exception.status == "500" && Rails.application.routes.recognize_path("/")), title: ("Return Home" if @exception.status == "500" && Rails.application.routes.recognize_path("/")) do %>

Changing this to if @exception.status == 500 works
(no quotes, comparing against an integer instead of a string)

I added the following span tags to the show page, to test whether the new comparison works:

  <span style="color:white;"><%= @exception.status == "500" %></span>
  <br />
  <span style="color:white;"><%= @exception.status == 500 %></span>

Below, you can see that it still regards the comparison using "500" as false,
but evaluates the comparion using 500 as true.

screen shot 2017-07-10 at 5 03 44 pm

Is this something unique to Rails 5? Perhaps some setting I toggled/forgot to toggle somewhere in a config file?

Changing "500" to 500 works just fine and allows me to go about my day, so this is purely motivated by curiosity.

Thanks!

Works for me and I'm using Rails 5.1.2 - do you have a repo I could look at? Or maybe you have some settings in application.rb which could be causing problems?

Ahhh, that'd probably do it -- I'm running Rails 5.0.1.

Unfortunately, a lot of the project is locked in to that version (just tried to update, and some of our weird, niche gems are leaning on ActiveRecord 5.0.0, which blocks the upgrade to Rails 5.1.2)

Again, I found a workaround (just changing "500" to 500), so this was mostly just curiosity.

I'd be fine chalking this up to Rails versioning weirdness and marking this resolved.

Thanks!

I've closed the issue but I doubt it is a Rails versioning problem. If you have niche gems which rely on 5.0, perhaps they could be causing a deeper conflict?

Off hand, do you know which gems are locking the version?

Sure.

We're using tinyTDS to connect to a SQL Server.

Based on my Lockfile, it looks like tiny_tds is reliant on composite_primary_keys, and both those gems are locked into activerecord 5.0.0