ruby on rails - No route found, even though there is that route specified in routes.rb (RailsAdmin conflict, I think) -
i added cancan authorization railsadmin , when access /admin
unauthorized user, error:
actioncontroller::routingerror @ / no route matches {:controller=>"home"}
this routes.rb
looks like:
myapp::application.routes.draw mount railsadmin::engine => '/admin', :as => 'rails_admin' mount piggybak::engine => '/checkout', :as => 'piggybak' devise_for :users, :path_names => { :sign_up => "register", :sign_in => "login", :sign_out => "logout", :settings => "settings" }, :controllers => {:confirmations => "confirmations"} devise_scope :user "login", :to => "devise/sessions#new" "register", :to => "devise/registrations#new" "settings", :to => "devise/registrations#edit" "logout", :to => "devise/sessions#destroy" end "downloads/show" match "downloads" => "downloads#index", via: :get resources :items devise_for :users resources :users authenticated :user root :to => 'home#index' end root :to => "home#index" end
it throwing error bit of application.rb
class applicationcontroller < actioncontroller::base protect_from_forgery rescue_from cancan::accessdenied |exception| redirect_to root_path, :alert => exception.message end end
once go other page , click on link links_to root_path
works. when try access railsadmin when not allowed, throws error.
ideally, cancan saying should - redirect root_path
message.
although, 1 thing jumps mind using gem better_errors
. causing this?
here full dump of server log of error:
started "/admin" 127.0.0.1 @ 2013-05-08 13:59:31 -0500 processing railsadmin::maincontroller#dashboard html user load (2.1ms) select "users".* "users" "users"."id" = 18 limit 1 (0.7ms) select count(*) "roles" inner join "users_roles" on "roles"."id" = "users_roles"."role_id" "users_roles"."user_id" = 18 , (((roles.name = 'admin') , (roles.resource_type null) , (roles.resource_id null))) (0.7ms) select count(*) "roles" inner join "users_roles" on "roles"."id" = "users_roles"."role_id" "users_roles"."user_id" = 18 , (((roles.name = 'seller') , (roles.resource_type null) , (roles.resource_id null))) completed 404 not found in 27ms actioncontroller::routingerror - no route matches {:controller=>"home"}: (gem) actionpack-3.2.13/lib/action_controller/metal/exceptions.rb:11:in `initialize' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:544:in `raise_routing_error' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:540:in `rescue in generate' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:532:in `generate' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:573:in `generate' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:598:in `url_for' (gem) actionpack-3.2.13/lib/action_dispatch/routing/url_for.rb:148:in `url_for' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:220:in `root_path' app/controllers/application_controller.rb:5:in `block in <class:applicationcontroller>' (gem) activesupport-3.2.13/lib/active_support/rescuable.rb:80:in `rescue_with_handler' (gem) actionpack-3.2.13/lib/action_controller/metal/rescue.rb:15:in `rescue_with_handler' (gem) actionpack-3.2.13/lib/action_controller/metal/rescue.rb:32:in `rescue in process_action' (gem) actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:in `process_action' (gem) actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' (gem) activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument' (gem) activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument' (gem) activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument' (gem) actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in `process_action' (gem) actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:in `process_action' (gem) activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:18:in `process_action' (gem) newrelic_rpm-3.6.1.88/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:38:in `block in process_action' (gem) newrelic_rpm-3.6.1.88/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:318:in `perform_action_with_newrelic_trace' (gem) newrelic_rpm-3.6.1.88/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:37:in `process_action' (gem) actionpack-3.2.13/lib/abstract_controller/base.rb:121:in `process' (gem) actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process' (gem) actionpack-3.2.13/lib/action_controller/metal.rb:203:in `dispatch' (gem) actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' (gem) actionpack-3.2.13/lib/action_controller/metal.rb:246:in `block in action' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `dispatch' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in `call' (gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call' (gem) journey-1.0.4/lib/journey/router.rb:56:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call' (gem) railties-3.2.13/lib/rails/engine.rb:479:in `call' (gem) railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing' (gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call' (gem) journey-1.0.4/lib/journey/router.rb:56:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call' (gem) rack-pjax-0.7.0/lib/rack/pjax.rb:12:in `call' (gem) newrelic_rpm-3.6.1.88/lib/new_relic/rack/error_collector.rb:12:in `call' (gem) newrelic_rpm-3.6.1.88/lib/new_relic/rack/agent_hooks.rb:18:in `call' (gem) newrelic_rpm-3.6.1.88/lib/new_relic/rack/browser_monitoring.rb:16:in `call' (gem) bullet-4.6.0/lib/bullet/rack.rb:10:in `call' (gem) meta_request-0.2.3/lib/meta_request/middlewares/app_request_handler.rb:11:in `call' (gem) rack-contrib-1.1.0/lib/rack/contrib/response_headers.rb:17:in `call' (gem) meta_request-0.2.3/lib/meta_request/middlewares/headers.rb:16:in `call' (gem) meta_request-0.2.3/lib/meta_request/middlewares/meta_request_handler.rb:13:in `call' (gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call' (gem) warden-1.2.1/lib/warden/manager.rb:34:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' (gem) rack-1.4.5/lib/rack/etag.rb:23:in `call' (gem) rack-1.4.5/lib/rack/conditionalget.rb:25:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call' (gem) remotipart-1.0.5/lib/remotipart/middleware.rb:30:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call' (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context' (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call' (gem) activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call' (gem) activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__4139764133977678969__call__3020020767411987846__callbacks' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks' (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:65:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call' (gem) better_errors-0.8.0/lib/better_errors/middleware.rb:84:in `protected_app_call' (gem) better_errors-0.8.0/lib/better_errors/middleware.rb:79:in `better_errors_call' (gem) better_errors-0.8.0/lib/better_errors/middleware.rb:56:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' (gem) railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app' (gem) railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call' (gem) activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged' (gem) railties-3.2.13/lib/rails/rack/logger.rb:16:in `call' (gem) quiet_assets-1.0.2/lib/quiet_assets.rb:18:in `call_with_quiet_assets' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call' (gem) rack-1.4.5/lib/rack/methodoverride.rb:21:in `call' (gem) rack-1.4.5/lib/rack/runtime.rb:17:in `call' (gem) activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call' (gem) rack-1.4.5/lib/rack/lock.rb:15:in `call' (gem) actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call' (gem) railties-3.2.13/lib/rails/engine.rb:479:in `call' (gem) railties-3.2.13/lib/rails/application.rb:223:in `call' (gem) rack-1.4.5/lib/rack/content_length.rb:14:in `call' (gem) railties-3.2.13/lib/rails/rack/log_tailer.rb:17:in `call' (gem) thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process' (gem) thin-1.5.1/lib/thin/connection.rb:79:in `pre_process' (gem) thin-1.5.1/lib/thin/connection.rb:54:in `process' (gem) thin-1.5.1/lib/thin/connection.rb:39:in `receive_data' (gem) eventmachine-1.0.3/lib/eventmachine.rb:187:in `run' (gem) thin-1.5.1/lib/thin/backends/base.rb:63:in `start' (gem) thin-1.5.1/lib/thin/server.rb:159:in `start' (gem) rack-1.4.5/lib/rack/handler/thin.rb:13:in `run' (gem) rack-1.4.5/lib/rack/server.rb:268:in `start' (gem) railties-3.2.13/lib/rails/commands/server.rb:70:in `start' (gem) railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>' (gem) railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>' script/rails:6:in `<main>' started post "/admin/__better_errors/70312574550380/variables" 127.0.0.1 @ 2013-05-08 13:59:32 -0500
rescue_from cancan::accessdenied |exception| redirect_to main_app.root_path, :alert => exception.message end
see also: https://stackoverflow.com/a/7390376/1546887 et al
Comments
Post a Comment