Search code examples
ruby-on-railsdeviseroutesrails-admin

Use railsadmin as root app


I am using rails_admin as main app and i would like to have it accessible via / and not /admin path.

My current routes files looks like this:

Rails.application.routes.draw do
  mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
  devise_for :users
  root 'dashboard#index'
end

dashboard is just a simple page with a link to /admin that i want to get rid off.

A simple mount RailsAdmin::Engine => '/', as: 'rails_admin' does not work out as there is a redirect loop (from devise i guess).

Logs are

Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on 10.0.16.183:3000, CTRL+C to stop


Started GET "/" for 10.0.16.244 at 2016-01-15 14:19:55 +0100
Cannot render console from 10.0.16.244! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  ActiveRecord::SchemaMigration Load (0.3ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by RailsAdmin::MainController#dashboard as HTML
Completed 401 Unauthorized in 12ms (ActiveRecord: 0.0ms)


Started GET "/users/sign_in" for 10.0.16.244 at 2016-01-15 14:19:55 +0100
Cannot render console from 10.0.16.244! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by RailsAdmin::MainController#show as HTML
  Parameters: {"model_name"=>"users", "id"=>"sign_in"}
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)


Started GET "/users/sign_in" for 10.0.16.244 at 2016-01-15 14:19:55 +0100
Cannot render console from 10.0.16.244! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by RailsAdmin::MainController#show as HTML
Parameters: {"model_name"=>"users", "id"=>"sign_in"}
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)


...
continues a couple of time after timeout

Tried several things but nothing worked out.

Can somebody help out?


Solution

  • Was a devise issue and i found a solution in https://github.com/sferik/rails_admin/wiki/Troubleshoot Had to switch devise infront of engine mounting.

    Rails.application.routes.draw do
      devise_for :users
      mount RailsAdmin::Engine => '/', as: 'rails_admin'
      root 'dashboard#index'
    end