Skip to content
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

undefined local variable or method `current_user' for #<Tenon::IndexController... #10

Open
skinnyjames opened this issue Jun 28, 2016 · 2 comments

Comments

@skinnyjames
Copy link

skinnyjames commented Jun 28, 2016

Looks like an awesome CMS! Having some trouble getting it running though:

undefined local variable or method `current_user' for  #<Tenon::IndexController:0x0000000256e468>
   Extracted source (around line #41):
       def require_admin
         unless current_user && current_user.staff?
           flash[:warning] = "You're not authorized for that." if current_user
           redirect_to new_user_session_path
          end

running rails 5 with ruby-head
got tenon installed by adding the following gems to the Gemfile
em 'tenon'
gem 'devise'
gem 'client_side_validations'
gem 'activemodel-serializers-xml', git: 'https://github.com/rails/activemodel-serializers-xml'
gem 'draper', github: 'audionerd/draper', branch: 'rails5'

I'm also getting warnings about using deprecated methods

DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can       
access the original method using super. (called from <top (required)> at 
/home/webdev/repos/test/tenon/config/application.rb:6)

Sounds like a devise issue, any ideas?
I do know that running rake db:migrate didn't throw any devise errors.

@skinnyjames skinnyjames changed the title undefined local variable or method `current_user' for #<Tenon::IndexController:0x0000000256e468> undefined local variable or method `current_user' for #<Tenon::IndexController... Jun 28, 2016
@SeanRoberts
Copy link
Collaborator

Is Devise all set up? The documentation for linking Tenon up with an auth gem is pretty poor, so I apologize for that, but essentially your ApplicationController needs to have a current_user method available (eg. the one provided by Devise) and your User model (or whatever is returned by current_user) needs to respond to #staff?, #admin?, #super_admin?, and #contributor?

You can override Tenon::ApplicationPolicy if you don't want to worry supporting those last 3 roles, those are just roles we use in most of our applications.

Documentation for this whole thing is pretty sparse, feel free to open more issues if you get stuck.

@skinnyjames
Copy link
Author

Awesome, I'll try it out. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants