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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:22:49+00:00 2026-05-30T16:22:49+00:00

I just started developing with Ruby on Rails and I am looking for a

  • 0

I just started developing with Ruby on Rails and I am looking for a dynamic authorization plugin, that enables the administrator to associate permissions to roles and roles to users.

I found some post here at stackoverflow and in some forums and also some podcasts at railscasts.org targeting this subject but they all refering to acl9, declarative_authorization, Aegis, restful acl or even Authlogic which isn’t an authorization but an authentication plugin. The other ones do not offer the needed functionality.

So could someone tell me if it is possible to setup a web interface using ruby on rails to administrate the user roles?

So for now I migrated my database using the folowing migration.

class AddRolesAndRightsTables < ActiveRecord::Migration
  def self.up
    create_table :roles_users do |t|
      t.integer :role_id
      t.integer :user_id 
    end

    create_table :roles do |t|
      t.string :name
    end

    create_table :rights_roles do |t|
      t.integer :right_id 
      t.integer :role_id
    end

    create_table :rights do |t|
      t.string :name
      t.string :controller
      t.string :action
    end
  end

  def self.down
    drop_table :roles_users
    drop_table :roles
    drop_table :rights_roles
    drop_table :rights
  end
end

And in addition to some views and controller actions I added the following action to the ApplicationController.

def check_authorization
  user = User.find(session[:user])
  unless user.roles.detect do |role|
    role.rights.select do |right|
      right.action == action_name && right.controller == self.class.controller_path
    end
  end

  redirect_back_or user
  flash[:notice] = "You are not authorized to view the page you requested."
  return false
end

Running the Right.synchronize_with_controllers (see the Blog-Post from Wolfman-Blog), I get the following Error.

syntax error, unexpected $end, expecting kEND (line 17 in application_controller)
  • 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-30T16:22:51+00:00Added an answer on May 30, 2026 at 4:22 pm

    I will suggest Ryan Bate’s cancan. It took me a while to understand how it works, but it’s really worth the effort to learn.

    In my full program, I am able to use a simple load_and_authorize_resource for all my controllers and add extra bits here and there to finish it up.

    Hopefully, there is no confusion between authentication and authorzation as well. If you want to quickly scaffold an admin interface, I suggest Active Admin.

    Otherwise, It’s probably more flexible to use cancan and namespace an admin controller =)

    Update

    To get a simple roles based permission interface based on cancan, where you probably create roles and assign permissions to them.

    User belongs_to Role
    
    Role has_many Users
    Role has_and_belongs_to_many Permissions
    
    Permissions has_and_belongs_to_many Roles
    

    Each Permission record defines an a Model and the RESTful action you can do to it.

    If you only need to define a Role but its permissions are static, I suggest you can just write them into Ability.rb in cancan and just do away with the Permission model.

    Sorry I can’t give you exact code because I haven’t had a need to implement a permissions based model.

    Cancan Railscast
    http://railscasts.com/episodes/192-authorization-with-cancan

    Another great Cancan tutorial
    http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise-and-cancan-customizing-devise-controllers/

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

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

Sidebar

Related Questions

I have just started looking at developing a plugin for Eclipse and I found
Our team has just started developing for the Sitecore CMS. We find that after
HI all, I'm just getting started with developing for Android. I'm looking to port
I've only just started learning ruby on rails and I would like to create
I just started iOS development am currently developing an application that just reads data
I am just getting started developing my first Android app, and one function that
I've just started developing a small C++ program using GraphViz's graph library and noticed
I have just started with wordpress and want to start developing my own themes.
I just started practicing TDD in my projects. I'm developing a project now using
I've just started working on an existing CakePHP project. I will be developing a

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.