Reputation: 2497
I am trying to access
POST http://localhost:3000/login
MyEngine routes
devise_for :accounts, { class_name: 'MyEngine::Account', skip: [:sessions, :registration, :password] }
as :account do
post 'login', to: 'sessions#create'
end
My Application Routes
Rails.application.routes.draw do
mount MyEngine::Engine => '/engine', as: 'engine'
end
Commented isolation Space
module MyEngine
class Engine < ::Rails::Engine
#isolate_namespace MyEngine
end
end
Error after hitting POST http://localhost:3000/login
#<ActionController::RoutingError: No route matches [POST] \"/login\">
How to access login method of Engine from URL path directly?
Upvotes: 0
Views: 379
Reputation: 1359
The error uninitialized constant SessionsController happening because rails not able to locate your sessions controller so if you are overriding default devise specify custom controller path inside routes.
Engine routes
devise_for :accounts, { class_name: 'MyEngine::Account', skip: [:sessions, :registration, :password], controllers: { sessions: "my_engine/sessions"} } as :account do
post 'login', to: 'sessions#create'
end
controllers: { sessions: "my_engine/sessions"}
here you can see i have specify the sessions path.
config/routes.rb
Rails.application.routes.draw do
# your main routes
mount MyEngine::Engine => '/engine', as: 'engine'
end
your sessions controller will be as follows:
MyEngine::SessionsController < Devise::SessionsController
end
Upvotes: 1