How do I go to Admin Panel right after installing Rails Admin

1,042 views
Skip to first unread message

waseem ahmad

unread,
Jan 23, 2012, 6:59:06 PM1/23/12
to rails...@googlegroups.com
Dear all,

I installed rails_admin in my rails 3.2 application as documented in the Readme. I'm using devise with all the default configurations. When prompted for name of the user model, I gave it admin_user.

I started my server and when I try to go to http://localhost:300/admin, I'm redirected to my application's root_path. This makes a little sense as I have am not signed in as an admin user in my application. And that is because I have not yet created any admin users in my application. My questions are:

1. How do I create an admin user for my application?

And once I have created this user, since going to /admin redirects me to /, I have my second question.

2. How do I sign into admin section of my application using admin user created in first question?

Thanks!

Benoit Bénézech

unread,
Jan 24, 2012, 2:14:13 AM1/24/12
to rails...@googlegroups.com
Usually http://0.0.0.0:3000/users/sign_in or http://0.0.0.0:3000/admin_users/sign_in will sign you in, then you shouldn't be redirected anymore.
There is a sign up link there, or you can go to http://0.0.0.0:3000/admin_users/sign_up

waseem ahmad

unread,
Jan 24, 2012, 2:23:04 AM1/24/12
to rails...@googlegroups.com


On Tue, Jan 24, 2012 at 12:44 PM, Benoit Bénézech <benoit....@gmail.com> wrote:
Usually http://0.0.0.0:3000/users/sign_in or http://0.0.0.0:3000/admin_users/sign_in will sign you in, then you shouldn't be redirected anymore.
There is a sign up link there, or you can go to http://0.0.0.0:3000/admin_users/sign_up

Somehow `$ rails g rails_admin:install` did not generate AdminUser model. I tried doing it again and it generated AdminUser model and related migration file. I ran the migration. That also put a `devise_for :admin_users` in my `routes.rb`. So far so good.

Now when I try to go to http://localhost:3000/admin_users/sign_up or /admin_users/sign_in or /admin, I am stuck in an infinite redirection. Following is part of my server logs:

Started GET "/admin" for 127.0.0.1 at 2012-01-24 12:51:01 +0530
Processing by RailsAdmin::MainController#dashboard as HTML
Completed 401 Unauthorized in 1ms


Started GET "/admin_users/sign_in" for 127.0.0.1 at 2012-01-24 12:51:01 +0530
Processing by RailsAdmin::MainController#show as HTML
  Parameters: {"model_name"=>"_users", "id"=>"sign_in"}
Completed 401 Unauthorized in 1ms


Started GET "/admin_users/sign_in" for 127.0.0.1 at 2012-01-24 12:51:01 +0530
Processing by RailsAdmin::MainController#show as HTML
  Parameters: {"model_name"=>"_users", "id"=>"sign_in"}
Completed 401 Unauthorized in 0ms


Started GET "/admin_users/sign_in" for 127.0.0.1 at 2012-01-24 12:51:01 +0530
Processing by RailsAdmin::MainController#show as HTML
  Parameters: {"model_name"=>"_users", "id"=>"sign_in"}
Completed 401 Unauthorized in 0ms


Started GET "/admin_users/sign_in" for 127.0.0.1 at 2012-01-24 12:51:01 +0530
Processing by RailsAdmin::MainController#show as HTML
  Parameters: {"model_name"=>"_users", "id"=>"sign_in"}
Completed 401 Unauthorized in 0ms


Started GET "/admin_users/sign_in" for 127.0.0.1 at 2012-01-24 12:51:01 +0530
Processing by RailsAdmin::MainController#show as HTML
  Parameters: {"model_name"=>"_users", "id"=>"sign_in"}
Completed 401 Unauthorized in 0ms


Started GET "/admin_users/sign_in" for 127.0.0.1 at 2012-01-24 12:51:01 +0530
Processing by RailsAdmin::MainController#show as HTML
  Parameters: {"model_name"=>"_users", "id"=>"sign_in"}
Completed 401 Unauthorized in 0ms

It happens till my browser craps out.

--
Waseem
Blog: http://babygnu.blogspot.com
Twitter: http://twitter.com/_waseem

Benoit Bénézech

unread,
Jan 24, 2012, 2:40:14 AM1/24/12
to rails...@googlegroups.com
lol

Rails engine router is beeing a little greedy!

It matches '/admin_users/sign_in'
to RailsAdmin Engine :: '_users/sign_in' which you're not authorized to see.

I see 2 solution: use a different URL scope for RailsAdmin, or a different user name.

waseem ahmad

unread,
Jan 24, 2012, 2:52:37 AM1/24/12
to rails...@googlegroups.com
I will go with the first one. Thanks for all your help.

On a side note perhaps this quirk should be documented in the README. I'm happy to send a pulll request. But not before weekend.

Benoit Bénézech

unread,
Jan 25, 2012, 6:32:47 AM1/25/12
to rails...@googlegroups.com
You can edit the wiki, there is a https://github.com/sferik/rails_admin/wiki/Known-issues section, it will only take a minute.

Matthew Powers

unread,
Jan 24, 2014, 11:50:56 AM1/24/14
to rails...@googlegroups.com, couga...@gmail.com
This StackOverflow post helped me solve this bug: http://stackoverflow.com/questions/16448233/no-route-found-even-though-there-is-that-route-specified-in-routes-rb-railsadm

Here is the solution from the post:
rescue_from CanCan::AccessDenied do |exception|
  redirect_to main_app.root_path, :alert => exception.message
end
Reply all
Reply to author
Forward
0 new messages