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

INFO: is it working on mongodb/mongoid ? #2

Open
lgs opened this issue Dec 23, 2011 · 0 comments
Open

INFO: is it working on mongodb/mongoid ? #2

lgs opened this issue Dec 23, 2011 · 0 comments

Comments

@lgs
Copy link

lgs commented Dec 23, 2011

I've an app which mix MongoDB and MySQL, I had a try with rails_blog_engine, but got the following error :

`undefined local variable or method `current_user' for #<RailsBlogEngine::PostsController:0xba5d9fc>`

I'm actually using omniauth/mongoid user model, setting :

field :admin, type: Boolean in my app/models/user.rb,

in app/controllers/application_controller.rb I've got :


private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
def current_ability
@current_ability ||= ::Ability.new(current_admin)
end

my app/models/ability.rb is like the following :

  class Ability
    include CanCan::Ability
    include RailsBlogEngine::Ability
    def initialize(user)
         user ||= User.new # guest user (not logged in)
         if user.admin?
           can :manage, :all
         else
           can :read, :all
         end
         can :update, Article, :published => true
    end
  end
  
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

1 participant