-
-
Notifications
You must be signed in to change notification settings - Fork 369
Closed
Description
We have the following mailer helper:
class MyMailerHelper
include Split::EncapsulatedHelper
def test_enabled?
ab_test('my_test', 'disabled', 'enabled') == 'enabled'
end
endand we call test_enabled? from a mailer view. This ends up raising an error:
ActionView::Template::Error:
undefined method `params' for #<MyMailer:0x007ff87555bd18>
The problem is this line in Split::EncapsulatedHelper:
_params = defined?(params) ? params : {}Due to a Rails bug (rails/rails#15613), defined?(params) returns true even though the method is not defined. The view delegates params, along with other methods, to the controller (and in this case, the "controller" is a mailer, which doesn't define that method).
I think Rails is the right place to fix the bug, but it would probably still be worthwhile to work around the issue in Split. A couple of options for this:
- Put a
begin/rescuearound the call toparams. - Don't call
paramsat all; if there's aparamsmethod defined, then you're probably in a controller anyway, so you could just useSplit::Helper.
Thoughts?
Thanks!
Tony
Metadata
Metadata
Assignees
Labels
No labels