brentd / xray-rails

☠️ A development tool that reveals your UI's bones
MIT License
1.22k stars 79 forks source link

fix undefined method 'variant' for nil:NilClass ActionController #render_to_text change API #38

Closed shemerey closed 10 years ago

shemerey commented 10 years ago

I've tried to use xray-rails with rails 4.1 and it just blows up with nil no method error. It looks like we have to provide request object for ActionController::Base directly.

Here is the patch to fix it

NoMethodError - undefined method `variant' for nil:NilClass:
  actionpack (4.1.0.rc1) lib/abstract_controller/rendering.rb:109:in `_normalize_render'
  actionpack (4.1.0.rc1) lib/abstract_controller/rendering.rb:42:in `render_to_string'
  actionpack (4.1.0.rc1) lib/action_controller/metal/rendering.rb:21:in `render_to_string'
  xray-rails (0.1.12) lib/xray/middleware.rb:65:in `xray_bar'
  xray-rails (0.1.12) lib/xray/middleware.rb:40:in `block in call'
  xray-rails (0.1.12) lib/xray/middleware.rb:40:in `call'
  warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.3) lib/warden/manager.rb:34:in `call'
  rack (1.5.2) lib/rack/etag.rb:23:in `call'
  rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
  rack (1.5.2) lib/rack/head.rb:11:in `call' 
brentd commented 10 years ago

Thanks for the PR! However I'm somewhat hesitant to merge because it looks like this issue was patched in Rails recently: rails/rails#14125. Considering it though because I doubt this will actually break anything; it'll just be unnecessary code once the next RC is released.

shemerey commented 10 years ago

Yep it looks like it has been fixed in rails, so very nice :-), thx for this note

juno commented 10 years ago

Rails 4.1.0 had released, but it looks like not contains that fix. :cry:

I think we need this PR as a workaround until rails has updated. What do you think?

brentd commented 10 years ago

Aaand looks like they've just backported the fix for next release. Le sigh.

Screw it, I'll do a bit of testing with this patch and get this merged in ASAP.

juno commented 10 years ago

@brentd Thank you :+1:

brentd commented 10 years ago

Alright, this is in 0.1.14 with one other small tweak for Rails 4.1.0 support. Thanks @shemerey and sorry for the delay all!

siera26 commented 10 years ago

Thanks for this patch =)