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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:25:06+00:00 2026-05-25T13:25:06+00:00

With a standard install of Rails_Admin using Devise for authentication and CanCan for authorization,

  • 0

With a standard install of Rails_Admin using Devise for authentication and CanCan for authorization, accessing http://localhost:3000/admin as a non-admin user produces the following server log:

Started GET "/admin" for 127.0.0.1 at 2011-08-09 22:46:10 -0400
  Processing by RailsAdmin::MainController#index as HTML
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
Completed 404 Not Found in 151ms

ActionController::RoutingError (No route matches {:controller=>"gyms"}):
  app/controllers/application_controller.rb:5:in `block in <class:ApplicationController>'

Everything up until the last part seems ok. As far as I can tell, CanCan rescues the exception properly and attempts to redirect to root_url via the following code:

class ApplicationController < ActionController::Base
  protect_from_forgery

  rescue_from CanCan::AccessDenied do |exception|
    redirect_to root_url, :alert => exception.message
  end
end

TopOut::Application.routes.draw do
  mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
  devise_for :users

  resources :gyms

  root :to => "gyms#index"
end

But for some reason, in redirecting to root_url, CanCan is only attempting to hit

{:controller=>"gyms"}

rather than

{:controller=>"gyms", :action=>"index"}

Is this possibly an issue with CanCan? Or is there some particular facet of redirect_to or root_url which I missed in the docs?

Note: this is a duplicate of an issue I opened on CanCan’s github page, so I’ll be sure to close one if the other is solved.

  • 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-25T13:25:07+00:00Added an answer on May 25, 2026 at 1:25 pm

    Based on feedback from users at Github, it appears that routes are being name_scoped and so this is expected behavior.

    Proper fix is to call root_url from main_app as follows:

    rescue_from CanCan::AccessDenied do |exception|
      redirect_to main_app.root_url, :alert => exception.message
    end
    

    Credit for the solution goes to bbenezech at https://github.com/sferik/rails_admin/issues/658

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

Sidebar

Related Questions

How do you install scripts on non-standard ports (ports other than the default 80)
I am trying to install some Perl modules into a non-standard location, let's call
Using the standard gem for using Markaby with Sinatra, listed at http://www.sinatrarb.com/extensions-wild.html sudo gem
I am using: Windows XP Python 2.6.2 (standard install from python.org) git version 1.6.5.1-preview20091022
Python 2.4.x - I cannot install any non-standard modules. *nix environment. So I've got
I want to update/upgrade the standard Leopard install of Sqlite3 to >3.5 to use
I have a standard .NET windows service written in C#. Can it install itself
I've just finished re-installing my OS, and as always install and test standard tools
Using standard mysql functions is there a way to write a query that will
I am in the early stages of building an app using Rails 3. User

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.