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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:35:57+00:00 2026-05-23T08:35:57+00:00

Looking for some general advice and tips about using cancan on our latest rails3

  • 0

Looking for some general advice and tips about using cancan on our latest rails3 project.

We’re building an ordering system which we use internally and provide restricted client access. These include:

Superadmin
Superaccounts
Supertechs 
Clientadmin
Clientaccounts
Clienttechs

In our views, we’ve previously used a combination of:

<% if can? :manage User %>

And

<% if current_user.role_ids.include?(2) %>

I suspect the latter is bad practice and would appreciate finding out how to best achieve the same method.

We’re also a little confused about how to deal with many roles.

What’s the best way to provide access to multiple user groups – i.e. superadmin and supertechs?

  • 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-23T08:35:58+00:00Added an answer on May 23, 2026 at 8:35 am

    I think the best option to replace

    <% if current_user.role_ids.include?(2) %>
    

    is to create a method for each role inside the model, for example:

    class Company < ActiveRecord::Base
      .
      . 
      def super_admin?
        self.role_ids.include?(2)
      end
      .
      .
    

    This way you will remove the query logic from the views and keep it on the controller and you will also be able access the roles by simply doing:

    <% if current_user.super_admin? %>
    

    Hope it helps 🙂

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

Sidebar

Related Questions

I'm looking for some general advice on how to go about finding items 'like'
Looking for some general advice here. Option 1. Would it be best to have
So I've seen this question , but I'm looking for some more general advice:
I’m looking for some samples/tutorials/general pointers in doing either of the following. 1) Create
Looking at some code I'm maintaining in System Verilog I see some signals that
I was just looking through some information about Google's protocol buffers data interchange format.
I'm looking for a general strategy/advice on how to handle invalid UTF-8 input from
Action Helpers are recommended in general over extending Zend_Controller_Action . Looking at some of
I am looking for some advice on how to construct a very low memory
I am new to Android programming, and looking for some general knowledge. I am

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.