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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:55:53+00:00 2026-06-14T21:55:53+00:00

I am using Devise and Cancan gems on a Rails 3.1 app. I added

  • 0

I am using Devise and Cancan gems on a Rails 3.1 app.

I added several additional columns to User.

I managed to define the abilities and they work fine, I can see that it works but I haven’t figured out how do I unauthorize actions (such as :update) since I don’t have access to Devise or users controller?

How do that work?

  • 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-14T21:55:55+00:00Added an answer on June 14, 2026 at 9:55 pm

    Or, try using the following in ability.rb

     if user.role? :admin
      can [:create, :read], [Model1, Model2]
     end
    
     if user.role? :user
      can [:read], Model1, :id => user.id
     end
    

    That will allow admins to create or read but not update. And allow users to read Model1 if it belongs to them. If you create custom actions, like “copy_model”, you could add the same to ability.rb

     ...
     can [:copy_model, :read], Model1, :id => user.id
     ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am using Devise for user authentication in my rails app. I have
I have two entities. User and Role. I am using Devise and CanCan. They
I am using cancan, devise, and omniauth in a rails app. I'm quite happy
I'm developing a Rails 3 app using Devise and CanCan. The app allows anonymous
I am using devise 2.1.0 for my rails app 3.2.3. Here is what I
I have a rails app that is using Devise perfectly in development. I have
Using Rails 3.1.3 with Devise 1.5.3. My app has accounts and users. Each account
I'm using devise as registration engine in my rails 3.1 app. How can i
I'm using Devise and Rack::SSLEnforcer in a Rails app. When users receive their confirmation
I'm trying to get some basic authentication/authorization with devise/cancan with Rails. Rather than using

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.