I'm having trouble accessing the cookies object in my cell views via helper
. My code looks like this:
#cell
helper SessionsHelper
#cell view
signed_in?
#sessions helper
signed_in?
cookies.sth
end
I'm getting the error: undefined local variable or method
cookies'`.
How do I make cookies visible there?
Alternatively, I'd like to pass Helper as an object collaborator to my cell, because this helper contains a lot of useful methods. Is doing SessionHelper.new
the correct way to do that?
<%= render_cell :my_cell, :display, session_helper: SessionsHelper.new %>
I now see that SessionsHelper
is in fact a module, so I cannot invoke the new()
method. What should I do with undefined cookies?
I always define
signed_in?
inApplicationController
. (Therecookies
is available) And then do:to make it available as a helper method.
As for your second question:
session_helper: SessionsHelper.new
is not necessary. All methods from all helpers are available all views.