ruby-on-railsdeviserails-cellsrails-cells-4

Rails Cells 4: access Devise helpers


I have a simple Cells example that I would like to integrate with Devise and Rails. However, all examples and questions seem to be for Cells 3. The following fails in my app (line numbers added).

line 1: class UserCell < Cell::ViewModel
line 2:   include Devise::Controllers::Helpers
line 3:
line 4:   def index
line 5:     render
line 6:   end
line 7: end

Raises this error for line 2.

undefined method `helper_method' for UserCell:Class

Solution

  • Turns out that Cells is no longer configured to work the same way with Rails by default (via Cell::Rails). I had to add abstract controller helpers, but this got me all of the devise helpers in my cell automatically.

    class UserCell < Cell::ViewModel
       include AbstractController::Helpers
       include Devise::Controllers::Helpers
    
       def index
         render
       end
     end