我根据资源名称(帐户)有多个子域,例如
我想从地址栏中删除资源名称
school.mydomain.com/schools/sign_in 至 school.mydomain.com/sign_in
这是routes.rb文件
# school employee / teacher routes and resources
devise_for :employees, :skip => [:registrations], controllers: { sessions: 'employees/sessions', passwords: 'employees/passwords' }
devise_scope :employee do
get 'employees/edit' => 'employees/registrations#edit', :as => 'edit_employee_registration'
put 'employees' => 'employees/registrations#update', :as => 'employee_registration'
end
resources :employee
# school admin routes and resources
devise_for :schools, :skip => [:registrations], controllers: { sessions: 'schools/sessions', passwords: 'schools/passwords' }
devise_scope :school do
get 'schools/edit' => 'schools/registrations#edit', :as => 'edit_school_registration'
put 'schools' => 'schools/registrations#update', :as => 'school_registration'
end
resources :school
# student routes and resource
devise_for :students, :skip => [:registrations], controllers: { sessions: 'students/sessions', passwords: 'students/passwords' }
devise_scope :school_district do
get 'students/edit' => 'students/registrations#edit', :as => 'edit_student_registration'
put 'students' => 'students/registrations#update', :as => 'student_registration'
end
resources :student
答案 0 :(得分:0)
您可以在Configuring routes设计文档
中详细了解相关信息我在项目routes.rb
file中对此进行了测试,方法是将devise_for
更改为
Rails.application.routes.draw do
devise_for :users, path: ''
end
这是您在yourdomain/sign_in
new_user_session GET /sign_in(.:format) devise/sessions#new
以及rake routes
new_user_password GET /password/new(.:format) devise/passwords#new
edit_user_password GET /password/edit(.:format) devise/passwords#edit
user_password PATCH /password(.:format) devise/passwords#update
PUT /password(.:format) devise/passwords#update
POST /password(.:format) devise/passwords#create
cancel_user_registration GET /cancel(.:format) devise/registrations#cancel
new_user_registration GET /sign_up(.:format) devise/registrations#new
edit_user_registration GET /edit(.:format) devise/registrations#edit
user_registration PATCH / devise/registrations#update
PUT / devise/registrations#update
DELETE / devise/registrations#destroy
POST / devise/registrations#create
所以我引用
配置路由
Devise还附带默认路线。如果您需要自定义它们,您应该可以通过devise_for方法完成它。它接受以下几个选项:class_name,:path_prefix等,包括更改I18n的路径名的可能性:
devise_for :users, path: 'auth', path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification', unlock: 'unblock', registration: 'register', sign_up: 'cmon_let_me_in' }
请务必查看devise_for文档以获取详细信息。
因此,在devise_for
api文档中,您可以更好地了解如何使用path
和path_names
请务必不要在这些网址之间产生冲突