" home "}" I set Rails_Admin as instructed and I also use Devise. When I try to g...">

Rails_Admin shows routing error "No route matches {: controller =>" home "}"

I set Rails_Admin as instructed and I also use Devise. When I try to go to "/ admin", I get the following error:

Routing Error No route matches {:controller=>"home"} 

Here are my .rb routes:

 Ot::Application.routes.draw do resources :badgeships resources :badges resources :profiles resources :universities resources :degrees resources :jobs resources :resources resources :communities resources :networks resources :topics do resources :posts end get 'topics/tag/:tag', to: 'topics#index', as: :topic_tag get 'resources/tag/:tag', to: 'resources#index', as: :resource_tag root :to => 'home#index' devise_for :users, path_names: {sign_in: "login", sign_out: "logout"} mount RailsAdmin::Engine => '/admin', :as => 'rails_admin' end 

Here is my rails_admin.rb initializer:

 RailsAdmin.config do |config| config.main_app_name = ["Cool app", "BackOffice"] # or somethig more dynamic config.main_app_name = Proc.new { |controller| [ "Cool app", "BackOffice - #{controller.params[:action].try(:titleize)}" ] } end 

Any idea on how to get rails_admin to work correctly?

UPDATED: Here are my rake routes:

 [RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it. badgeships GET /badgeships(.:format) badgeships#index POST /badgeships(.:format) badgeships#create new_badgeship GET /badgeships/new(.:format) badgeships#new edit_badgeship GET /badgeships/:id/edit(.:format) badgeships#edit badgeship GET /badgeships/:id(.:format) badgeships#show PUT /badgeships/:id(.:format) badgeships#update DELETE /badgeships/:id(.:format) badgeships#destroy badges GET /badges(.:format) badges#index POST /badges(.:format) badges#create new_badge GET /badges/new(.:format) badges#new edit_badge GET /badges/:id/edit(.:format) badges#edit badge GET /badges/:id(.:format) badges#show PUT /badges/:id(.:format) badges#update DELETE /badges/:id(.:format) badges#destroy profiles GET /profiles(.:format) profiles#index POST /profiles(.:format) profiles#create new_profile GET /profiles/new(.:format) profiles#new edit_profile GET /profiles/:id/edit(.:format) profiles#edit profile GET /profiles/:id(.:format) profiles#show PUT /profiles/:id(.:format) profiles#update DELETE /profiles/:id(.:format) profiles#destroy universities GET /universities(.:format) universities#index POST /universities(.:format) universities#create new_university GET /universities/new(.:format) universities#new edit_university GET /universities/:id/edit(.:format) universities#edit university GET /universities/:id(.:format) universities#show PUT /universities/:id(.:format) universities#update DELETE /universities/:id(.:format) universities#destroy degrees GET /degrees(.:format) degrees#index POST /degrees(.:format) degrees#create new_degree GET /degrees/new(.:format) degrees#new edit_degree GET /degrees/:id/edit(.:format) degrees#edit degree GET /degrees/:id(.:format) degrees#show PUT /degrees/:id(.:format) degrees#update DELETE /degrees/:id(.:format) degrees#destroy jobs GET /jobs(.:format) jobs#index POST /jobs(.:format) jobs#create new_job GET /jobs/new(.:format) jobs#new edit_job GET /jobs/:id/edit(.:format) jobs#edit job GET /jobs/:id(.:format) jobs#show PUT /jobs/:id(.:format) jobs#update DELETE /jobs/:id(.:format) jobs#destroy resources GET /resources(.:format) resources#index POST /resources(.:format) resources#create new_resource GET /resources/new(.:format) resources#new edit_resource GET /resources/:id/edit(.:format) resources#edit resource GET /resources/:id(.:format) resources#show PUT /resources/:id(.:format) resources#update DELETE /resources/:id(.:format) resources#destroy communities GET /communities(.:format) communities#index POST /communities(.:format) communities#create new_community GET /communities/new(.:format) communities#new edit_community GET /communities/:id/edit(.:format) communities#edit community GET /communities/:id(.:format) communities#show PUT /communities/:id(.:format) communities#update DELETE /communities/:id(.:format) communities#destroy networks GET /networks(.:format) networks#index POST /networks(.:format) networks#create new_network GET /networks/new(.:format) networks#new edit_network GET /networks/:id/edit(.:format) networks#edit network GET /networks/:id(.:format) networks#show PUT /networks/:id(.:format) networks#update DELETE /networks/:id(.:format) networks#destroy topic_posts GET /topics/:topic_id/posts(.:format) posts#index POST /topics/:topic_id/posts(.:format) posts#create new_topic_post GET /topics/:topic_id/posts/new(.:format) posts#new edit_topic_post GET /topics/:topic_id/posts/:id/edit(.:format) posts#edit topic_post GET /topics/:topic_id/posts/:id(.:format) posts#show PUT /topics/:topic_id/posts/:id(.:format) posts#update DELETE /topics/:topic_id/posts/:id(.:format) posts#destroy topics GET /topics(.:format) topics#index POST /topics(.:format) topics#create new_topic GET /topics/new(.:format) topics#new edit_topic GET /topics/:id/edit(.:format) topics#edit topic GET /topics/:id(.:format) topics#show PUT /topics/:id(.:format) topics#update DELETE /topics/:id(.:format) topics#destroy topic_tag GET /topics/tag/:tag(.:format) topics#index resource_tag GET /resources/tag/:tag(.:format) resources#index root / home#index new_user_session GET /users/login(.:format) devise/sessions#new user_session POST /users/login(.:format) devise/sessions#create destroy_user_session DELETE /users/logout(.:format) devise/sessions#destroy user_omniauth_authorize /users/auth/:provider(.:format) devise/omniauth_callbacks#passthru {:provider=>/facebook/} user_omniauth_callback /users/auth/:action/callback(.:format) devise/omniauth_callbacks#(?-mix:facebook) user_password POST /users/password(.:format) devise/passwords#create new_user_password GET /users/password/new(.:format) devise/passwords#new edit_user_password GET /users/password/edit(.:format) devise/passwords#edit PUT /users/password(.:format) devise/passwords#update cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel user_registration POST /users(.:format) devise/registrations#create new_user_registration GET /users/sign_up(.:format) devise/registrations#new edit_user_registration GET /users/edit(.:format) devise/registrations#edit PUT /users(.:format) devise/registrations#update DELETE /users(.:format) devise/registrations#destroy rails_admin /admin RailsAdmin::Engine Routes for RailsAdmin::Engine: dashboard GET / rails_admin/main#dashboard index GET|POST /:model_name(.:format) rails_admin/main#index new GET|POST /:model_name/new(.:format) rails_admin/main#new export GET|POST /:model_name/export(.:format) rails_admin/main#export bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete history_index GET /:model_name/history(.:format) rails_admin/main#history_index bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action show GET /:model_name/:id(.:format) rails_admin/main#show edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete history_show GET /:model_name/:id/history(.:format) rails_admin/main#history_show show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app 

This is how I set rails_admin:

  rails g rails_admin:install SECURITY WARNING: No secret option provided to Rack::Session::Cookie. This poses a security threat. It is strongly recommended that you provide a secret to prevent exploits that may be possible from crafted cookies. This will not be supported in future versions of Rack, and future versions will even invalidate your existing user cookies. Called from: /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/actionpack-3.2.9/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'. - Hello, RailsAdmin installer will help you set things up! - I need to work with Devise, let look at a few things first: - Checking for a current installation of devise... - Found it! - Looks like you've already installed it, good! ? Where do you want to mount rails_admin? Press <enter> for [admin] > manage gsub config/routes.rb route mount RailsAdmin::Engine => '/manage', :as => 'rails_admin' - And you already set it up, good! We just need to know about your user model name... - We found 'user' (should be one of 'user', 'admin', etc.) ? Correct Devise model name if needed. Press <enter> for [user] > User - Now setting up devise with user model name 'User': generate devise SECURITY WARNING: No secret option provided to Rack::Session::Cookie. This poses a security threat. It is strongly recommended that you provide a secret to prevent exploits that may be possible from crafted cookies. This will not be supported in future versions of Rack, and future versions will even invalidate your existing user cookies. Called from: /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/actionpack-3.2.9/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'. invoke active_record create db/migrate/20130214195616_add_devise_to_users.rb insert app/models/user.rb route devise_for :users - Now you'll need an initializer... - You already have a config file. You're updating, heh? I'm generating a new 'rails_admin.rb.example' that you can review. create config/initializers/rails_admin.rb.example /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.9/lib/active_record/reflection.rb:385:in `block in source_reflection': undefined method `klass' for nil:NilClass (NoMethodError) from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.9/lib/active_record/reflection.rb:385:in `collect' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.9/lib/active_record/reflection.rb:385:in `source_reflection' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.9/lib/active_record/reflection.rb:375:in `rescue in foreign_key' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.9/lib/active_record/reflection.rb:373:in `foreign_key' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/adapters/active_record.rb:292:in `association_foreign_key_lookup' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/adapters/active_record.rb:72:in `block in associations' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/adapters/active_record.rb:65:in `map' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/adapters/active_record.rb:65:in `associations' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/fields/factories/association.rb:6:in `block in <top (required)>' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/fields.rb:54:in `call' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/fields.rb:54:in `block (2 levels) in factory' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/fields.rb:54:in `each' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/fields.rb:54:in `find' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/fields.rb:54:in `block in factory' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/fields.rb:50:in `each' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/fields.rb:50:in `factory' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/has_fields.rb:130:in `_fields' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/has_fields.rb:128:in `_fields' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/has_fields.rb:108:in `all_fields' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/rails_admin/config/has_fields.rb:83:in `fields' from (erb):64:in `block in template' from (erb):53:in `map' from (erb):53:in `template' from /Users/iyerushalmi/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/erb.rb:838:in `eval' from /Users/iyerushalmi/.rvm/rubies/ruby-1.9.3-p374/lib/ruby/1.9.1/erb.rb:838:in `result' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/file_manipulation.rb:117:in `block in template' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/create_file.rb:54:in `call' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/create_file.rb:54:in `render' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/create_file.rb:63:in `block (2 levels) in invoke!' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/create_file.rb:63:in `open' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/create_file.rb:63:in `block in invoke!' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/empty_directory.rb:133:in `call' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/empty_directory.rb:133:in `invoke_with_conflict_check' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/create_file.rb:61:in `invoke!' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions.rb:95:in `action' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/create_file.rb:26:in `create_file' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/actions/file_manipulation.rb:116:in `template' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/rails_admin-0.4.4/lib/generators/rails_admin/install_generator.rb:66:in `install' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/task.rb:27:in `run' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/invocation.rb:126:in `block in invoke_all' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/invocation.rb:126:in `each' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/invocation.rb:126:in `map' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/invocation.rb:126:in `invoke_all' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/group.rb:238:in `dispatch' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/thor-0.17.0/lib/thor/base.rb:434:in `start' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.9/lib/rails/generators.rb:171:in `invoke' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.9/lib/rails/commands/generate.rb:12:in `<top (required)>' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require' from /Users/iyerushalmi/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.9/lib/rails/commands.rb:29:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' 
+4
source share
5 answers

EDIT: fix found. See better_errors Gem.) I get an exception report and I see the correct error message in local variables at the point where the routing fails.

I also see, thanks to the better wrapper better_errors, that the ActionController that creates the RoutingError is RailsAdmin::MainController . This suggests that we need to figure out how to tell RailsAdmin to redirect to the root path of the application, and not to the root path of the kernel.

+5
source

The reason your routing is not working is because you entered

 mount RailsAdmin::Engine => '/admin', :as => 'rails_admin' 

at the bottom of the routes.rb . Understand that routes take priority from top to bottom. When the URL is routed, it will start at the top of the list and go down. As soon as he sees the appropriate route, Rails will send it to the appropriate controller and action.

Generally, I find it best to move the third-party api to the top of the API list. If the problem ends, I can change my own routes. Much easier to handle.

So, move the Devise and RailsAdmin routes to the beginning and let us know what you get.

+1
source

Try moving development and administration routes to the top of the routes file.

0
source

I have the same problem, but it only occurs when entering my User model. If I am not subscribed, it is redirected to my sign_in page.

Update

What happened to me was that my user model was not allowed to use :manage resources accessed by the panel.

As soon as I enabled this permission, the admin panel worked.

0
source

Use main_app in routes.rb to reference the main route of the application, as described in the documentation .

 class ApplicationController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| redirect_to main_app.root_path, :alert => exception.message end end 
0
source

All Articles