I do authorization through "login" and because of this there is such an error:
Started POST "/auth/sign_in" for 10.12.4.5 at 2018-08-07 10:20:55 +0500
LoadError (Unable to autoload constant Overrides::SessionsController, expected /home/admin/Рабочий стол/demo/backend/app/controllers/overrides/sessions_controller.rb to define it):
activesupport (5.1.6) lib/active_support/dependencies.rb:512:in
load_missing_constant' activesupport (5.1.6) lib/active_support/dependencies.rb:202:in
const_missing' activesupport (5.1.6) lib/active_support/inflector/methods.rb:284:inconst_get' activesupport (5.1.6) lib/active_support/inflector/methods.rb:284:in
block in constantize' activesupport (5.1.6) lib/active_support/inflector/methods.rb:267:ineach' activesupport (5.1.6) lib/active_support/inflector/methods.rb:267:in
inject' activesupport (5.1.6) lib/active_support/inflector/methods.rb:267:inconstantize' activesupport (5.1.6) lib/active_support/dependencies.rb:583:in
get' activesupport (5.1.6) lib/active_support/dependencies.rb:614:inconstantize' actionpack (5.1.6) lib/action_dispatch/http/request.rb:85:in
controller_class_for' actionpack (5.1.6) lib/action_dispatch/http/parameters.rb:99:inbinary_params_for?' actionpack (5.1.6) lib/action_dispatch/http/parameters.rb:90:in
set_binary_encoding' actionpack (5.1.6) lib/action_dispatch/http/parameters.rb:67:inpath_parameters=' actionpack (5.1.6) lib/action_dispatch/journey/router.rb:48:in
block in serve' actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:ineach' actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in
serve' actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:844:incall' warden (1.2.7) lib/warden/manager.rb:36:in
block in call' warden (1.2.7) lib/warden/manager.rb:35:incatch' warden (1.2.7) lib/warden/manager.rb:35:in
call' rack (2.0.5) lib/rack/etag.rb:25:incall' rack (2.0.5) lib/rack/conditional_get.rb:38:in
call' rack (2.0.5) lib/rack/head.rb:12:incall' activerecord (5.1.6) lib/active_record/migration.rb:556:in
call' actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:26:inblock in call' activesupport (5.1.6) lib/active_support/callbacks.rb:97:in
run_callbacks' actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:24:incall' actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in
call' actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59:incall' actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in
call' railties (5.1.6) lib/rails/rack/logger.rb:36:incall_app' railties (5.1.6) lib/rails/rack/logger.rb:24:in
block in call' activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:inblock in tagged' activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in
tagged' activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:intagged' railties (5.1.6) lib/rails/rack/logger.rb:24:in
call' actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:incall' request_store (1.4.1) lib/request_store/middleware.rb:19:in
call' actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:incall' rack (2.0.5) lib/rack/runtime.rb:22:in
call' activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:incall' actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in
call' actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:incall' rack (2.0.5) lib/rack/sendfile.rb:111:in
call' rack-cors (1.0.2) lib/rack/cors.rb:97:incall' railties (5.1.6) lib/rails/engine.rb:522:in
call' puma (3.11.4) lib/puma/configuration.rb:225:incall' puma (3.11.4) lib/puma/server.rb:632:in
handle_request' puma (3.11.4) lib/puma/server.rb:446:inprocess_client' puma (3.11.4) lib/puma/server.rb:306:in
block in run' puma (3.11.4) lib/puma/thread_pool.rb:120:in `block in spawn_thread'TypeError (superclass mismatch for class SessionsController):
app/controllers/overrides/sessions_controller.rb:1:in `'
/overrides/sessions_controller.rb:
class SessionsController < DeviseTokenAuth::ApplicationController
def resource_data(opts = {})
opts[:resource_json] || @resource.as_json
end
def render_new_error
render json: {
errors: [I18n.t("devise_token_auth.sessions.not_supported")]
}, status: 405
end
def render_create_success
render json: {
sponsor: resource_data(resource_json: @resource.userable.token_validation_response)
}
end
def render_create_error_not_confirmed
render json: {
errors: [I18n.t("devise_token_auth.sessions.not_confirmed", login: @resource.login)]
}, status: 404
end
def render_create_error_bad_credentials
render json: {
errors: [I18n.t("devise_token_auth.sessions.bad_credentials")]
}, status: 402
end
def render_destroy_success
render json: {
}, status: 200
end
def render_destroy_error
render json: {
errors: [I18n.t("devise_token_auth.sessions.user_not_found")]
}, status: 404
end
end
application_controller.rb:
class ApplicationController < ActionController::API
include DeviseTokenAuth::Concerns::SetUserByToken
end
routes.rb:
Rails.application.routes.draw do
mount_devise_token_auth_for 'User', at: 'auth', controllers: {
sessions: 'overrides/sessions'
}
end
class Overrides::SessionsController
? It looks like it should be namespaced. – jvillian