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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:36:12+00:00 2026-06-15T19:36:12+00:00

I am new to Ruby on Rails. I am using Devise and CanCan. I

  • 0

I am new to Ruby on Rails. I am using Devise and CanCan. I would like to create groups of users so they will be in a group and be able to have a group leader. The group leader can add / edit / delete users only from that group.

I have followed http://edapx.com/2012/04/18/authorization-and-user-management-in-rails/ am not sure how to create groups now. Is it possible to do this in CanCan?

  • 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-06-15T19:36:13+00:00Added an answer on June 15, 2026 at 7:36 pm

    See if this answer can help you: https://stackoverflow.com/a/13747645/367611

    Basically, you’ll have something like this:

    class Ability
      include CanCan::Ability
    
      initialize(user)
        can :manage, User, groups: {id: user.led_group_ids}
        can :manage, Group, id: user.led_group_ids
      end
    end
    

    Then in your User model, something like this:

    class User < ActiveRecord::Base
    
      has_many :groups
    
      def led_groups
        @led_groups ||= groups.where(leader: true)
      end
    
      def led_group_ids
        @led_group_ids ||= led_groups.collect(&:id)
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Ruby and Rails, but my team is interested in using Redmine
new on ruby and using windows xp and rails 3, i want to send
I have built a very simple blog application using Ruby on Rails. New to
I'm new to Ruby on Rails, looking at using it for an app that
I'm using Rails 3.0.9, Ruby 1.9.2, Devise 1.3.4 and has a need in Devise
I'm using Devise for authentication in Ruby on Rails and I'm overriding the registration
I have created a new rails app (3.2.8) using Devise. All is setup properly,
I am using cucumber and RSpec for my new ruby on rails application and
I am using cucumber to write features for a new ruby on rails application.
In my new Ruby on rails application I want to find the users country

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.