You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a recursive method and ancestors[1..-1] appears to be designed to remove the current object's class from the iterator, with the assumption that the current object is its own first ancestor.
eg if ancestors returns
[ ActionController::Base, ActiveRecord::Railties::ControllerRuntime, ....... ]
[1..-1] removes the first element which is assumed to be the current object, in this case ActionController::Base.
However this fails if other gem modules (eg wicked_pdf) are designed to prepend to the front of the ancestors chain.
ancestors returns
[WickedPdf::PdfHelper, ActionController::Base, ActiveRecord::Railties::ControllerRuntime, .......
[1..-1] removes the first element, in this case the prepend-ed WickedPdf::PdfHelper, leaving the current object ( ActionController::Base) in the iterator which causes the infinite loop.
FIX: Replace
ancestors[1..-1].reverse.eachdo |mod|
WITH
(ancestors - [self]).reverse.eachdo |mod|
Thanks
Simon
The text was updated successfully, but these errors were encountered:
I experienced this as well and fixed it similarly. I didn't get down to what was causing it so good find on prepending being the issue. We use WickedPdf as well. 👍
mherold
added a commit
to emjot/declarative_authorization
that referenced
this issue
Jun 28, 2017
HI
in_controller.rb line 600 ish
ancestors[1..-1] is the issue.
This is a recursive method and ancestors[1..-1] appears to be designed to remove the current object's class from the iterator, with the assumption that the current object is its own first ancestor.
eg if ancestors returns
[ ActionController::Base, ActiveRecord::Railties::ControllerRuntime, ....... ]
[1..-1] removes the first element which is assumed to be the current object, in this case ActionController::Base.
However this fails if other gem modules (eg wicked_pdf) are designed to prepend to the front of the ancestors chain.
See Nice Module#prepend explanation here
For example: prepend excerpt from the wicked_pdf gem:
ancestors returns
[WickedPdf::PdfHelper, ActionController::Base, ActiveRecord::Railties::ControllerRuntime, .......
[1..-1] removes the first element, in this case the prepend-ed WickedPdf::PdfHelper, leaving the current object ( ActionController::Base) in the iterator which causes the infinite loop.
FIX: Replace
WITH
Thanks
Simon
The text was updated successfully, but these errors were encountered: