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 6950143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:03:24+00:00 2026-05-27T14:03:24+00:00

For Rails I see quite a few gem options for role-based access control (cancan,

  • 0

For Rails I see quite a few gem options for role-based access control (cancan, cantango, etc.) However, I’m not finding any gems for group-membership-based access control. Here is a simplified description of what I’m trying to accomplish:

Users: a, b, c, d 
Groups: y, z
Group Membership: y has a and b; z has c and d
Posts: m, n
Ownership: a owns m; c owns n

Group y is marked as a public group. m can be seen by all users
Group z is marked as a private group.  n can only be seen by c and d

So nothing too fancy or complex, essentially a capability similar to file system access control (e.g. read-write-execute across owner-group-public [without the ‘execute’ of course].)

It looks like Radiant (with some extra plug-ins) can provide page-level group-membership access control, but I don’t want/need a whole CMS and I would prefer something that is model-based (like cancan) vs. page/path based. (BTW, I’m using Devise for my user model – is there something in Devise I missed?)

How are private/public user groupings implemented in Rails? Only through a Rails-based CMS? Am I missing something basic? Or is this use-case rarely tackled in the Rails community?

  • 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-27T14:03:25+00:00Added an answer on May 27, 2026 at 2:03 pm

    I found the answer for this and thought I would post it in case anyone else is looking for it.

    CanCan does support group capability via “Hash of Conditions”. The idea is that post is tagged with a :group_id (belongs_to a group) and users has_many groups. Then you can set up the “hash of conditions” within the can statement as follows:

    can :manage, Post, :group => { :id => user.group_ids }
    

    The “hash of conditions” is documented further here:

    https://github.com/ryanb/cancan/wiki/Defining-Abilities

    Thanks to @Jason_Noble for pointing me back to the cancan docs where I finally found it.

    p.s. one implementation note. If you wish to have some Posts public and some Posts private, you can set up a default group of which each user is a member. All public Posts should then be tagged with the default group_id.

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

Sidebar

Related Questions

I am all new to rails, however quite familiar with regular MVC programming like
I cannot figure out why rails/ruby cannot see this gem, despite each telling me
In PHP, I'm trying to steal a page from the Rails playbook (see 'Using
I often see things like this in rails views: <% form_tag some_path do -%>
When using Rails date_select with :prompt => true I see some very strange behavior
[see later answer for more] I think this is just a simple rails question,
I'm having trouble getting a rails app on Dreamhost's Passenger to see compiled libraries
I have a ruby on rails application and it would be nice to see
Is there an easy way to see the actual SQL generated by a rails
I'm trying to use Rails validations for a form text box to see if

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.