Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with ActiveAdmin #156

Closed
bluengreen opened this issue Feb 17, 2015 · 11 comments
Closed

Not compatible with ActiveAdmin #156

bluengreen opened this issue Feb 17, 2015 · 11 comments

Comments

@bluengreen
Copy link

It seems this gem is not compatible with activeadmin. It clobbers the routes that activeadmin generates with devise. devise_token_auth always takes over and causes a 500 error. Regardless of the namspacing and scoping I give the devise_token_auth gem.

@lynndylanhurley
Copy link
Owner

What do your routes look like?

Also, please take a look at the issue reporting guidelines.

@bluengreen
Copy link
Author

version: 0.1.32.beta5
No headers - get a 500 error

Routes:
MyApp::Application.routes.draw do
devise_for :users, controllers: { sessions: 'sessions' }

devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)

namespace :api, defaults: { format: :json } do
scope :v1 do
mount_devise_token_auth_for 'User', at: 'auth', skip: [:omniauth_callbacks]
end
end
end

Stacktrace:
[757fc169-b2f1-4034-a0bd-19647216c96b] [RWp6R3BySytVOC9n] Processing by Admin::DashboardController#index as HTML
[757fc169-b2f1-4034-a0bd-19647216c96b] [RWp6R3BySytVOC9n] Completed 500 Internal Server Error in 1ms
[757fc169-b2f1-4034-a0bd-19647216c96b] [RWp6R3BySytVOC9n]
ArgumentError (wrong number of arguments (1 for 0)):
activesupport (4.2.0) lib/active_support/core_ext/class/attribute.rb:106:in block (2 levels) in class_attribute' devise_token_auth (0.1.32.beta5) app/controllers/devise_token_auth/concerns/set_user_by_token.rb:19:inset_user_by_token'
devise_token_auth (0.1.32.beta5) lib/devise_token_auth/controllers/helpers.rb:115:in current_admin_user' devise_token_auth (0.1.32.beta5) lib/devise_token_auth/controllers/helpers.rb:103:inauthenticate_admin_user!'
/Users/pnovess/.rvm/gems/ruby-2.1.4@di-skate/bundler/gems/activeadmin-ed1fbca8c64a/lib/active_admin/base_controller.rb:39:in authenticate_active_admin_user' activesupport (4.2.0) lib/active_support/callbacks.rb:427:inblock in make_lambda'
activesupport (4.2.0) lib/active_support/callbacks.rb:163:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:163:inblock in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:169:inblock in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:234:inblock in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:234:inblock in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:234:inblock in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:169:inblock in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:169:inblock in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:92:in_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in _run_process_action_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in process_action' actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:inprocess_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in block in process_action' activesupport (4.2.0) lib/active_support/notifications.rb:164:inblock in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.2.0) lib/active_support/notifications.rb:164:ininstrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in process_action' actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:inprocess_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (4.2.0) lib/abstract_controller/base.rb:137:inprocess'
actionview (4.2.0) lib/action_view/rendering.rb:30:in process' actionpack (4.2.0) lib/action_controller/metal.rb:195:indispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in dispatch' actionpack (4.2.0) lib/action_controller/metal.rb:236:inblock in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in call' actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:indispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in serve' actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:inblock in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in each' actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:inserve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/rack/agent_hooks.rb:30:in traced_call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/rack/browser_monitoring.rb:23:in traced_call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/rack/developer_mode.rb:56:in traced_call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:55:incall'
warden (1.2.3) lib/warden/manager.rb:35:in block in call' warden (1.2.3) lib/warden/manager.rb:34:incatch'
warden (1.2.3) lib/warden/manager.rb:34:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
rack (1.6.0) lib/rack/etag.rb:24:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
rack (1.6.0) lib/rack/conditionalget.rb:25:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
rack (1.6.0) lib/rack/head.rb:13:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in context' rack (1.6.0) lib/rack/session/abstract/id.rb:220:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' activerecord (4.2.0) lib/active_record/migration.rb:378:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:88:in_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in _run_call_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
railties (4.2.0) lib/rails/rack/logger.rb:38:in call_app' railties (4.2.0) lib/rails/rack/logger.rb:20:inblock in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:intagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.2.0) lib/rails/rack/logger.rb:20:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' rack (1.6.0) lib/rack/methodoverride.rb:22:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' rack (1.6.0) lib/rack/runtime.rb:18:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' rack (1.6.0) lib/rack/lock.rb:17:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' rack (1.6.0) lib/rack/sendfile.rb:113:incall'
newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in call' railties (4.2.0) lib/rails/engine.rb:518:incall'
railties (4.2.0) lib/rails/application.rb:164:in call' newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:incall'
rack (1.6.0) lib/rack/lock.rb:17:in call' rack (1.6.0) lib/rack/content_length.rb:15:incall'
rack (1.6.0) lib/rack/handler/webrick.rb:89:in service' /Users/pnovess/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/httpserver.rb:138:inservice'
/Users/pnovess/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/httpserver.rb:94:in run' /Users/pnovess/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/webrick/server.rb:295:inblock in start_thread'
logging (1.8.2) lib/logging/diagnostic_context.rb:323:in call' logging (1.8.2) lib/logging/diagnostic_context.rb:323:inblock in create_with_logging_context'

@bluengreen
Copy link
Author

Seems to interfere with the normal devise setup I have for the users resource despite the namespacing I followed from the FAQ section in the read me.

@lynndylanhurley
Copy link
Owner

Are you including the SetUserByToken concern in your ApplicationController like this?

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  include DeviseTokenAuth::Concerns::SetUserByToken
end

@bluengreen
Copy link
Author

Yes. I believe the resource_class method is the problem. I haven't gotten too far but I believe there is a similar method used by ActiveAdmin or ActiveSupport that doesn't require any parameters.

@lynndylanhurley
Copy link
Owner

I think ActiveAdmin may extend from your ApplicationController. As a test, can you try removing the include DeviseTokenAuth::Concerns::SetUserByToken statement to see if that fixes the ActiveAdmin problem?

@bluengreen
Copy link
Author

Yup. That fixes it. Of course now the token auth doesn't. :)

@lynndylanhurley
Copy link
Owner

So you will need to create another base controller for your API routes. Something like this:

# app/controllers/api_controller.rb
# API routes extend from this controller
class ApiController < ActionController::Base
  include DeviseTokenAuth::Concerns::SetUserByToken
end

# app/controllers/application_controller.rb
# leave this for ActiveAdmin, and any other non-api routes
class ApplicationController < ActionController::Base
end

I don't know why ActiveAdmin has anything to do with your main ApplicationController. It seems like a poor design choice on their part.

@bluengreen
Copy link
Author

Actually its the inherited_resources dependency in ActiveAdmin that inherits from the ApplicationController.

@bluengreen
Copy link
Author

Thanks for the update. I will try the workaround.

lynndylanhurley added a commit that referenced this issue Feb 23, 2015
Add FAQ item for use with ActiveAdmin. References #156
@lynndylanhurley
Copy link
Owner

@bluengreen - thanks for closing this one out. I just added a note in the README regarding this issue, let me know if there's anything else I should add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants