Skip to content

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

@lgs

Description

@lgs

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
  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions