Using Cells and Devise, when trying to access a Devise :current_#{mapping} (like current_user) I'm getting request as undefined errors:
ActionView::Template::Error (undefined local variable or method `request' for #)
I've included the Devise Helpers methods, but they access the web context request which isn't present in Cell::Base. My Cell controller looks something like this:
class ActivityCell < Cell::Base
include Devise::Controllers::Helpers
helper_method :current_user
def display
puts current_user.id # <-- Error starts here
...
end
end
I'm using RubyMine, when I debug the situation, inside a non-Cells normal Controller, self has request. Inside a Cells::Base Controller, request isn't around.
I found this snippet here which is supposed to show how to access request and other important bits from a Cells Controller, but it's a bit unclear how to simply get Devise to work as intended in a Cells Controller. e.g. Cells::Base makes request and whatever else Devise needs available
I think something might be wrong with my Cells version, but I'm using 3.8.3. (the latest) The reason I think this is because I also don't have "session" available as demonstrated here under item #4 "Controllers should be slim". I can't access session from a Cell::Base Controller. I don't know if this was only possible with Ruby 2.x previously and now with 3.x it's not possible. (article doesn't mention versions, but I see the comments were posted late 2010)
class CartCell < Cell::Base
def display
@user = session[:user]
render
end
Other than this issue, I'm super digging Cells. I'm using it for isolated widgets, which use jQuery AJAX to yank JSON from them for graphing purposes.
Any help would be appreciated. I need to know details about the current Devise user that's logged in!
As you already pointed out yourself ;-) just derive the cell from Cell::Rails and everything will work just fine.