Search code examples
ruby-on-railsruby-on-rails-plugins

How could I implement the permit directive through database in rails-authorization-plugin, in a way that an admin user can change?


I'd like to control the permit method with something like this

class SomethingController < ApplicationController permit :somerole end

where ':somerole' is a field in the database linked to a controller and an action. Something that an user with priviledge can administer and change.

Some Idea?


Solution

  • this is just for example i have

    class Admin::AdminController < ApplicationController
      before_filter :login_required
      before_filter :only_moderator_and_above
    
      layout 'admin'
    
      def only_moderator_and_above
        unless current_user.has_admin_access?
          flash[:notice] = CustomMessages.admin_permission_alert
          redirect_to '/'
        end
      end
    end