Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7022167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:32:46+00:00 2026-05-27T23:32:46+00:00

I need to create roles based permissions systems in my Rails app. I would

  • 0

I need to create roles based permissions systems in my Rails app. I would be totally happy with CanCan, but the main problem – it has to be dynamic, so that Admin has to be able to assign permissions and to create new roles. The permissions can be simple controller/action restrictions, and can be data related, for example some users can edit only their own profiles, and some of them can edit the profiles of all the users in the particular group. And it would be really nice to allow Admin to create new permissions.

What I’m thinking about is to store in db a controller/action, and some data related restrictions (I’m really confused here about the way to define them). So could you please give me some advice, what would be the best way to organize permissions?

Any thoughts are much appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:32:47+00:00Added an answer on May 27, 2026 at 11:32 pm

    If you like CanCan, then I think is best to use it. Here is a short tutorial about storing abilities in database so non-programmers can update them:

    https://github.com/ryanb/cancan/wiki/Abilities-in-Database

    If you really, really want to implement such system yourself. Depending on your needs, I will suggest for you to implement it as simple as possible.

    In the case you need only users to have access to modules(certain controllers). You can do:

    1. Store all users permissions in just like serialized fields -> http://apidock.com/rails/ActiveRecord/Base/serialize/class

      class User
      serialize :permissions, Array

      def access_to?(module)
      permissions.include? module.to_s
      end
      end

    some check when setting this field would be nice.

    1. Just make a check on top of every controller if the current user have access to this controller(section)

      class ApplicationController
      private

      def self.require_access_to(module)
         before_filter do |c|
           unless c.send(:current_user).try :access_to?(module)
             c.send :render_no_presmissions_page
           end
         end
      end
      

      end

      class AdminNewsController
      require_access_to :news
      end

    Of course this is just a start position, from where you can easily evolve.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a 2D int array of size 800x800. But doing so
I am trying to use forms authentication with Active Directory but I need roles
I need to execute some large file-based .sql scripts (to create/drop databases and tables
I need to create a few tests for the user roles in a web
I'm listing the models in my app so an admin can create custom roles:
I need create custom dialog and put JPanel into it. Is it possible?
i need create an email list sending to many emails. what is best solution
Need to create a custom DNS name server using C which will check against
I need to create a historical timeline starting from 1600's to the present day.
I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.