我希望有一个“帐户设置”页面,用于编辑名称和密码,以及一个“个人资料编辑”页面,用于更新个人资料图片和个人信息。用户编辑的默认设计路径是'/ edit',但我想将其设为'/ users /:id / account'。我还想让配置文件编辑页面的路径为'/ users /:id / edit_profile'。按照设计维基上的说明,我能够更改注册和登录路径,但它似乎不适用于其他路径。
配置/ routes.rb中
devise_for :user, :path => '', :path_names => { :sign_in => "signin", :sign_up => "signup", :edit => "profile" }
resources :users, only: [:index, :show]
resources :projects
root 'static_pages#home'
match '/help', to: 'static_pages#help', via: 'get'
match '/about', to: 'static_pages#about', via: 'get'
match '/contact', to: 'static_pages#contact', via: 'get'
rake routes
new_user_session GET /signin(.:format) devise/sessions#new
user_session POST /signin(.:format) devise/sessions#create
destroy_user_session DELETE /sign_out(.:format) devise/sessions#destroy
user_password POST /password(.:format) devise/passwords#create
new_user_password GET /password/new(.:format) devise/passwords#new
edit_user_password GET /password/edit(.:format) devise/passwords#edit
PATCH /password(.:format) devise/passwords#update
PUT /password(.:format) devise/passwords#update
cancel_user_registration GET /cancel(.:format) devise/registrations#cancel
user_registration POST / devise/registrations#create
new_user_registration GET /signup(.:format) devise/registrations#new
edit_user_registration GET /edit(.:format) devise/registrations#edit
PATCH / devise/registrations#update
PUT / devise/registrations#update
DELETE / devise/registrations#destroy
users GET /users(.:format) users#index
user GET /users/:id(.:format) users#show
projects GET /projects(.:format) projects#index
POST /projects(.:format) projects#create
new_project GET /projects/new(.:format) projects#new
edit_project GET /projects/:id/edit(.:format) projects#edit
project GET /projects/:id(.:format) projects#show
PATCH /projects/:id(.:format) projects#update
PUT /projects/:id(.:format) projects#update
DELETE /projects/:id(.:format) projects#destroy
root GET / static_pages#home
help GET /help(.:format) static_pages#help
about GET /about(.:format) static_pages#about
contact GET /contact(.:format) static_pages#contact
谢谢!
答案 0 :(得分:0)
我想制作' / users /:id / account'
为什么不做以下事情:
#config/routes.rb
resources :users, path_names: { edit: "account" } do
get :edit_profile #-> I presume you have an "edit_profile" controller action?
end
这将为您提供以下路线:
domain.com/users/:id/account #-> edit
domain.com/users/:id/edit_profile #-> edit_profile
-
Devise documentation建议您无法直接使用user
修改Devise
对象 - 它更多地用于定义系统的authentication
系统。