我正在使用RoR设计。 在重置密码中,如果您输错了电子邮件,应用程序会立即显示一些错误并重定向原始网址。
在我的应用中,原始网址就是这样。
http://localhost:3000/en/users/password/new
以某种方式在发送错误的电子邮件时重定向
http://localhost:3000/en/users/password/
通常,这可能是
http://localhost:3000/en/users/password/new
我无法弄清楚为什么会发生这种情况。并想知道什么是错的。 任何人都帮助我。
最佳
[附录] 这是我的密码相关路线。
$ rake routes
(in /Users/takamizawanoriaki/vegewel)
Prefix Verb URI Pattern Controller#Action
home_index GET /home/index(.:format) home#index
user_google_oauth2_omniauth_authorize GET|POST /users/auth/google_oauth2(.:format) users/omniauth_callbacks#passthru
user_google_oauth2_omniauth_callback GET|POST /users/auth/google_oauth2/callback(.:format) users/omniauth_callbacks#google_oauth2
user_facebook_omniauth_authorize GET|POST /users/auth/facebook(.:format) users/omniauth_callbacks#passthru
user_facebook_omniauth_callback GET|POST /users/auth/facebook/callback(.:format) users/omniauth_callbacks#facebook
user_twitter_omniauth_authorize GET|POST /users/auth/twitter(.:format) users/omniauth_callbacks#passthru
user_twitter_omniauth_callback GET|POST /users/auth/twitter/callback(.:format) users/omniauth_callbacks#twitter
user_confirmation POST /users/confirmation(.:format) devise/confirmations#create
new_user_confirmation GET /users/confirmation/new(.:format) devise/confirmations#new
GET /users/confirmation(.:format) devise/confirmations#show
shortcut GET /shortcut/:id(.:format) shortcut#show
GET /(:locale)(.:format) frontpage#index {:locale=>/en|ja/}
near GET (/:locale)/near(.:format) frontpage#near {:locale=>/en|ja/}
restaurant_nearby GET (/:locale)/restaurant_nearby(.:format) area#restaurant_nearby {:locale=>/en|ja/}
notification GET (/:locale)/notification(.:format) application#set_checked_notification {:locale=>/en|ja/}
notification_create GET (/:locale)/notification/create(.:format) notification#create {:locale=>/en|ja/}
notification_index GET (/:locale)/notification/index(.:format) notification#index {:locale=>/en|ja/}
restaurant GET (/:locale)/restaurant(.:format) restaurant#index {:locale=>/en|ja/}
GET (/:locale)/restaurant/:id(.:format) restaurant#show {:locale=>/en|ja/}
menu GET (/:locale)/menu(.:format) menu#index {:locale=>/en|ja/}
GET (/:locale)/menu/:id(.:format) menu#show {:locale=>/en|ja/}
area GET (/:locale)/area(.:format) area#index {:locale=>/en|ja/}
GET (/:locale)/area/:id(.:format) area#show {:locale=>/en|ja/}
restaurant_type GET (/:locale)/restaurant_type(.:format) restaurant_type#index {:locale=>/en|ja/}
GET (/:locale)/restaurant_type/:id(.:format) restaurant_type#show {:locale=>/en|ja/}
cuisine GET (/:locale)/cuisine(.:format) cuisine#index {:locale=>/en|ja/}
GET (/:locale)/cuisine/:id(.:format) cuisine#show {:locale=>/en|ja/}
product GET (/:locale)/product(.:format) product#index {:locale=>/en|ja/}
GET (/:locale)/product/:id(.:format) product#show {:locale=>/en|ja/}
shop GET (/:locale)/shop(.:format) shop#index {:locale=>/en|ja/}
GET (/:locale)/shop/:id(.:format) shop#show {:locale=>/en|ja/}
prefstate GET (/:locale)/prefstate(.:format) prefstate#index {:locale=>/en|ja/}
GET (/:locale)/prefstate/:id(.:format) prefstate#show {:locale=>/en|ja/}
GET (/:locale)/style_image/:id(.:format) style#show_image {:locale=>/en|ja/}
search GET (/:locale)/search(.:format) search#index {:locale=>/en|ja/}
batch GET (/:locale)/batch(.:format) batch#index {:locale=>/en|ja/}
privacy GET (/:locale)/privacy(.:format) privacy#index {:locale=>/en|ja/}
terms GET (/:locale)/terms(.:format) terms#index {:locale=>/en|ja/}
about_us GET (/:locale)/about_us(.:format) about_us#index {:locale=>/en|ja/}
feed GET (/:locale)/feed(.:format) feed#feed {:format=>/rss/, :locale=>/en|ja/}
knowledge_sprouts GET (/:locale)/knowledge_sprouts(.:format) knowledge_sprouts#index {:locale=>/en|ja/}
POST (/:locale)/knowledge_sprouts(.:format) knowledge_sprouts#create {:locale=>/en|ja/}
new_knowledge_sprout GET (/:locale)/knowledge_sprouts/new(.:format) knowledge_sprouts#new {:locale=>/en|ja/}
edit_knowledge_sprout GET (/:locale)/knowledge_sprouts/:id/edit(.:format) knowledge_sprouts#edit {:locale=>/en|ja/}
knowledge_sprout GET (/:locale)/knowledge_sprouts/:id(.:format) knowledge_sprouts#show {:locale=>/en|ja/}
PATCH (/:locale)/knowledge_sprouts/:id(.:format) knowledge_sprouts#update {:locale=>/en|ja/}
PUT (/:locale)/knowledge_sprouts/:id(.:format) knowledge_sprouts#update {:locale=>/en|ja/}
DELETE (/:locale)/knowledge_sprouts/:id(.:format) knowledge_sprouts#destroy {:locale=>/en|ja/}
answers GET (/:locale)/answers(.:format) answers#index {:locale=>/en|ja/}
POST (/:locale)/answers(.:format) answers#create {:locale=>/en|ja/}
new_answer GET (/:locale)/answers/new(.:format) answers#new {:locale=>/en|ja/}
edit_answer GET (/:locale)/answers/:id/edit(.:format) answers#edit {:locale=>/en|ja/}
answer GET (/:locale)/answers/:id(.:format) answers#show {:locale=>/en|ja/}
PATCH (/:locale)/answers/:id(.:format) answers#update {:locale=>/en|ja/}
PUT (/:locale)/answers/:id(.:format) answers#update {:locale=>/en|ja/}
DELETE (/:locale)/answers/:id(.:format) answers#destroy {:locale=>/en|ja/}
reviews GET (/:locale)/reviews(.:format) reviews#index {:locale=>/en|ja/}
POST (/:locale)/reviews(.:format) reviews#create {:locale=>/en|ja/}
new_review GET (/:locale)/reviews/new(.:format) reviews#new {:locale=>/en|ja/}
edit_review GET (/:locale)/reviews/:id/edit(.:format) reviews#edit {:locale=>/en|ja/}
review GET (/:locale)/reviews/:id(.:format) reviews#show {:locale=>/en|ja/}
PATCH (/:locale)/reviews/:id(.:format) reviews#update {:locale=>/en|ja/}
PUT (/:locale)/reviews/:id(.:format) reviews#update {:locale=>/en|ja/}
DELETE (/:locale)/reviews/:id(.:format) reviews#destroy {:locale=>/en|ja/}
product_reviews GET (/:locale)/product_reviews(.:format) product_reviews#index {:locale=>/en|ja/}
POST (/:locale)/product_reviews(.:format) product_reviews#create {:locale=>/en|ja/}
new_product_review GET (/:locale)/product_reviews/new(.:format) product_reviews#new {:locale=>/en|ja/}
edit_product_review GET (/:locale)/product_reviews/:id/edit(.:format) product_reviews#edit {:locale=>/en|ja/}
product_review GET (/:locale)/product_reviews/:id(.:format) product_reviews#show {:locale=>/en|ja/}
PATCH (/:locale)/product_reviews/:id(.:format) product_reviews#update {:locale=>/en|ja/}
PUT (/:locale)/product_reviews/:id(.:format) product_reviews#update {:locale=>/en|ja/}
DELETE (/:locale)/product_reviews/:id(.:format) product_reviews#destroy {:locale=>/en|ja/}
relationships POST (/:locale)/relationships(.:format) relationships#create {:locale=>/en|ja/}
relationship DELETE (/:locale)/relationships/:id(.:format) relationships#destroy {:locale=>/en|ja/}
review_upholds POST (/:locale)/reviews/:review_id/upholds(.:format) upholds#create {:locale=>/en|ja/}
review_uphold DELETE (/:locale)/reviews/:review_id/upholds/:id(.:format) upholds#destroy {:locale=>/en|ja/}
GET (/:locale)/reviews(.:format) reviews#index {:locale=>/en|ja/}
POST (/:locale)/reviews(.:format) reviews#create {:locale=>/en|ja/}
GET (/:locale)/reviews/new(.:format) reviews#new {:locale=>/en|ja/}
GET (/:locale)/reviews/:id/edit(.:format) reviews#edit {:locale=>/en|ja/}
GET (/:locale)/reviews/:id(.:format) reviews#show {:locale=>/en|ja/}
PATCH (/:locale)/reviews/:id(.:format) reviews#update {:locale=>/en|ja/}
PUT (/:locale)/reviews/:id(.:format) reviews#update {:locale=>/en|ja/}
DELETE (/:locale)/reviews/:id(.:format) reviews#destroy {:locale=>/en|ja/}
product_review_upholds POST (/:locale)/product_reviews/:product_review_id/upholds(.:format) upholds#create {:locale=>/en|ja/}
product_review_uphold DELETE (/:locale)/product_reviews/:product_review_id/upholds/:id(.:format) upholds#destroy {:locale=>/en|ja/}
GET (/:locale)/product_reviews(.:format) product_reviews#index {:locale=>/en|ja/}
POST (/:locale)/product_reviews(.:format) product_reviews#create {:locale=>/en|ja/}
GET (/:locale)/product_reviews/new(.:format) product_reviews#new {:locale=>/en|ja/}
GET (/:locale)/product_reviews/:id/edit(.:format) product_reviews#edit {:locale=>/en|ja/}
GET (/:locale)/product_reviews/:id(.:format) product_reviews#show {:locale=>/en|ja/}
PATCH (/:locale)/product_reviews/:id(.:format) product_reviews#update {:locale=>/en|ja/}
PUT (/:locale)/product_reviews/:id(.:format) product_reviews#update {:locale=>/en|ja/}
DELETE (/:locale)/product_reviews/:id(.:format) product_reviews#destroy {:locale=>/en|ja/}
answer_upholds POST (/:locale)/answers/:answer_id/upholds(.:format) upholds#create {:locale=>/en|ja/}
answer_uphold DELETE (/:locale)/answers/:answer_id/upholds/:id(.:format) upholds#destroy {:locale=>/en|ja/}
GET (/:locale)/answers(.:format) answers#index {:locale=>/en|ja/}
POST (/:locale)/answers(.:format) answers#create {:locale=>/en|ja/}
GET (/:locale)/answers/new(.:format) answers#new {:locale=>/en|ja/}
GET (/:locale)/answers/:id/edit(.:format) answers#edit {:locale=>/en|ja/}
GET (/:locale)/answers/:id(.:format) answers#show {:locale=>/en|ja/}
PATCH (/:locale)/answers/:id(.:format) answers#update {:locale=>/en|ja/}
PUT (/:locale)/answers/:id(.:format) answers#update {:locale=>/en|ja/}
DELETE (/:locale)/answers/:id(.:format) answers#destroy {:locale=>/en|ja/}
knowledge_sprout_upholds POST (/:locale)/knowledge_sprouts/:knowledge_sprout_id/upholds(.:format) upholds#create {:locale=>/en|ja/}
knowledge_sprout_uphold DELETE (/:locale)/knowledge_sprouts/:knowledge_sprout_id/upholds/:id(.:format) upholds#destroy {:locale=>/en|ja/}
GET (/:locale)/knowledge_sprouts(.:format) knowledge_sprouts#index {:locale=>/en|ja/}
POST (/:locale)/knowledge_sprouts(.:format) knowledge_sprouts#create {:locale=>/en|ja/}
GET (/:locale)/knowledge_sprouts/new(.:format) knowledge_sprouts#new {:locale=>/en|ja/}
GET (/:locale)/knowledge_sprouts/:id/edit(.:format) knowledge_sprouts#edit {:locale=>/en|ja/}
GET (/:locale)/knowledge_sprouts/:id(.:format) knowledge_sprouts#show {:locale=>/en|ja/}
PATCH (/:locale)/knowledge_sprouts/:id(.:format) knowledge_sprouts#update {:locale=>/en|ja/}
PUT (/:locale)/knowledge_sprouts/:id(.:format) knowledge_sprouts#update {:locale=>/en|ja/}
DELETE (/:locale)/knowledge_sprouts/:id(.:format) knowledge_sprouts#destroy {:locale=>/en|ja/}
new_user_session GET (/:locale)/users/sign_in(.:format) devise/sessions#new {:locale=>/en|ja/}
user_session POST (/:locale)/users/sign_in(.:format) devise/sessions#create {:locale=>/en|ja/}
destroy_user_session DELETE (/:locale)/users/sign_out(.:format) devise/sessions#destroy {:locale=>/en|ja/}
user_password POST (/:locale)/users/password(.:format) devise/passwords#create {:locale=>/en|ja/}
new_user_password GET (/:locale)/users/password/new(.:format) devise/passwords#new {:locale=>/en|ja/}
edit_user_password GET (/:locale)/users/password/edit(.:format) devise/passwords#edit {:locale=>/en|ja/}
PATCH (/:locale)/users/password(.:format) devise/passwords#update {:locale=>/en|ja/}
PUT (/:locale)/users/password(.:format) devise/passwords#update {:locale=>/en|ja/}
cancel_user_registration GET (/:locale)/users/cancel(.:format) users/registrations#cancel {:locale=>/en|ja/}
user_registration POST (/:locale)/users(.:format) users/registrations#create {:locale=>/en|ja/}
new_user_registration GET (/:locale)/users/sign_up(.:format) users/registrations#new {:locale=>/en|ja/}
edit_user_registration GET (/:locale)/users/edit(.:format) users/registrations#edit {:locale=>/en|ja/}
PATCH (/:locale)/users(.:format) users/registrations#update {:locale=>/en|ja/}
PUT (/:locale)/users(.:format) users/registrations#update {:locale=>/en|ja/}
DELETE (/:locale)/users(.:format) users/registrations#destroy {:locale=>/en|ja/}
POST (/:locale)/users/confirmation(.:format) devise/confirmations#create {:locale=>/en|ja/}
GET (/:locale)/users/confirmation/new(.:format) devise/confirmations#new {:locale=>/en|ja/}
GET (/:locale)/users/confirmation(.:format) devise/confirmations#show {:locale=>/en|ja/}
user GET (/:locale)/users/:id(.:format) users#show {:locale=>/en|ja/}
following_user GET (/:locale)/users/:id/following(.:format) users#following {:locale=>/en|ja/}
followers_user GET (/:locale)/users/:id/followers(.:format) users#followers {:locale=>/en|ja/}
users GET (/:locale)/users(.:format) users#index {:locale=>/en|ja/}
POST (/:locale)/users(.:format) users#create {:locale=>/en|ja/}
new_user GET (/:locale)/users/new(.:format) users#new {:locale=>/en|ja/}
edit_user GET (/:locale)/users/:id/edit(.:format) users#edit {:locale=>/en|ja/}
GET (/:locale)/users/:id(.:format) users#show {:locale=>/en|ja/}
PATCH (/:locale)/users/:id(.:format) users#update {:locale=>/en|ja/}
PUT (/:locale)/users/:id(.:format) users#update {:locale=>/en|ja/}
DELETE (/:locale)/users/:id(.:format) users#destroy {:locale=>/en|ja/}
ahoy_engine /ahoy Ahoy::Engine
这里也是route.rb
# You can have the root of your site routed with "root"
# root 'welcome#index'
get 'home/index'
devise_for :users, skip: [:session, :password, :registration], controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
#Route for QR
resources :shortcut, only: [:show]
# Locale Information
scope "(:locale)", locale: /en|ja/ do
get '/' => 'frontpage#index'
resources :knowledge_sprouts
resources :answers
resources :reviews
resources :product_reviews
resources :relationships, only: [:create, :destroy]
resources :reviews, :product_reviews, :answers, :knowledge_sprouts do
resources :upholds, only: [:create, :destroy]
end
devise_for :users, skip: [:omniauth_callbacks], :controllers => { :registrations => 'users/registrations' }
resources :users, :only => [:show]
devise_scope :users do
get 'password' => redirect('password/new', status: 301)
end
resources :users do
member do
get :following, :followers
end
end
end
答案 0 :(得分:1)
首先,当您执行submit
密码时,会转到create
或update
操作,方法为PATCH
或PUT
或POST
。
是的,你可以强行让它重定向到
new
动作(但是它是 通过压倒来解决你的问题并不是一个好的解决方案 密码控制器。
Here您可以找到如何覆盖password_controller
。
干杯
答案 1 :(得分:0)
看起来它正常工作。 如果你检查你的路线,你会看到类似的东西:
urlpatterns = [
url(r'^(?P<analysis_id>\d+)$', login_required(views.analysis_detail), name="detail"),
url(r'^comparison$', login_required(views.analysis_comparison), name="comparison"),
]
这意味着rake routes | grep password
new_user_password GET (/:locale)/users/password/new(.:format) user/passwords#new
user_password PATCH (/:locale)/users/password(.:format) user/passwords#update
PUT (/:locale)/users/password(.:format) user/passwords#update
POST (/:locale)/users/password(.:format) user/passwords#create
页面呈现您的表单,http://localhost:3000/en/users/password/new
是表单提交数据的位置。
注意:的
如果您想通过输入网址或重新加载页面打开http://localhost:3000/en/users/password/
,则必须为http://localhost:3000/en/users/password/
请求设置路由器。在您的设计范围内:
[更新路线]
GET
希望它有所帮助。