为“十万个为什么”而努力!
现有路由器规则如下:
get 'my', to: 'users#profile'
get 'my/books', to: 'users#books'
devise_for :users, :controllers => {:omniauth_callbacks => 'users/omniauth_callbacks'}
resources :users, only: [:show, :edit, :update] do
member do
get :avatar
end
resources :books
end
执行rake routes
后,输出如下:
my GET /my(.:format) users#profile
my_books GET /my/books(.:format) users#books
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_omniauth_authorize GET|POST /users/auth/:provider(.:format) users/omniauth_callbacks#passthru {:provider=>/weibo/}
user_omniauth_callback GET|POST /users/auth/:action/callback(.:format) users/omniauth_callbacks#(?-mix:weibo)
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
avatar_user GET /users/:id/avatar(.:format) users#avatar
user_books GET /users/:user_id/books(.:format) books#index
POST /users/:user_id/books(.:format) books#create
new_user_book GET /users/:user_id/books/new(.:format) books#new
edit_user_book GET /users/:user_id/books/:id/edit(.:format) books#edit
user_book GET /users/:user_id/books/:id(.:format) books#show
PUT /users/:user_id/books/:id(.:format) books#update
DELETE /users/:user_id/books/:id(.:format) books#destroy
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
问题
/users/password/edit
(修改密码)页面,直接重定向到/users/:user_id/edit
页面。并且,提示“您已经登录”。 为什么会成重定向?如何才能不重定向?
用户注册
、修改用户信息
、修改密码
等 URL,有没有一种比较好的命名规则?