4

I am currently trying to use a Devise helper inside a service object

class ServiceObject
    include Devise::Controllers::Helpers

But I get

undefined method `helper_method' for ServiceObject:Class

Any idea how to use such a helper inside the service object?

stefano_cdn
  • 1,362
  • 2
  • 15
  • 29

2 Answers2

2

The problem is that helper_method is a method defined by ActionController::Base. So including the module only works in subclasses of them.

If the helper is already included in your ApplicationController you could simply use ApplicationController.new.method_to_call

Florian Eck
  • 495
  • 3
  • 13
0

Try using presentar. Probably you can use decorator gem. So that you can keep your presentation layer seperate and can be easily used any level of framework stack.

Rubyrider
  • 3,567
  • 1
  • 28
  • 34