New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing Devise Helper methods inside cell controllers and views #23
Comments
i have the same problems in a rails 3 app and just use signed_in?(:user) for the moment. when i tried to reproduce the problem in a blank rails 3 app, everything worked fine just by including "include Devise::Controllers::Helpers" in the Cell. i have no idea right now which part of my app-setup is responsible for this. |
Thanks for your inputs. While signed_in?(:user) seems to be working fine. I am getting stuck with resource_name while inserting login form inside cell view. I have included Devise::Controllers::Helpers in the cell. I am trying to keep the view code as close to devise generated view code as possible. Hence I am not directly using user model. Did you happen to face that problem? |
Apart from "include Devise::Controllers::Helpers", inserting Devise::Controllers::Helpers.define_helpers(User) helps me access rest of the devise helper methods. Not sure if this is the best way or the cleaner way to access devise helper methods. |
I got it working by calling helper_method :current_user and that's what José recommended, too! |
Thanks it works great... looks much cleaner too.. |
hey, did you try with a fresh rails 3 app? it's working without any extras, just include |
Hi, Yep I tried and yes it indeed works without any additional line... Its kind of strange because now when I run my app after removing "helper_method :current_user" its recognizing user_signed_in? method. I have still not figured out why it was giving me error earlier. But good news is that it now works with one line code and thats 50% improvement over 2 lines :-) Thanks a ton. |
thax! helper_method :current_user did the trick! |
Hi, i'm trying the following: app/cells/main_menu_cell.rb
display.html.haml
But i'm getting a undefined method `user_signed_in?' What could I be doing wrong? Edit: duh. I get it :). Had to use |
Hi,
I am using Devise as authentication plugin. Since login box is common
across all my pages, I have extracted that out as a cell. However, I
am getting errors while accessing devise helper methods such as
user_signed_in? etc. It is giving me undefined method error. Based on
the last post, I tried inserting "include
Devise::Controllers::Helpers". It still is giving me errors.
Here's the cell controller and the view code
app/cells/authenticate_cell.rb
app/cells/authenticate/login.html.rb
Thanks in advance.
The text was updated successfully, but these errors were encountered: