2012-07-20 31 views
0

我在我的rails應用程序中使用設計。由於某種原因,當你點擊按鈕「發送密碼重置指令」,輸入你的電子郵件後,它會帶你到這個URL /users/password.user的空白頁面。我不知道爲什麼要這樣做,也不知道如何改變它。發送密碼重置指令後的Rails設計重定向到錯誤的頁面

我不確切知道要發佈什麼代碼,因此只需評論您希望我添加的摘錄內容。謝謝。

爲了記錄,密碼重置電子郵件和更改密碼令牌完美地工作,它只有這個奇怪的重定向(或缺乏重定向)。

這些路線:

devise_for :users, :controllers => {:registrations => 'registrations', :invitations => 'invitations', :confirmations => 'confirmations'}, :except => [:show] 

密碼路徑助手是edit_password_url(@resource, :reset_password_token => @resource.reset_password_token)

的config.reset_password_keys:

config.reset_password_keys = [ :login ] 

密碼重置表單:

  <head> 
       <%= stylesheet_link_tag "passreset" %> 
      </head> 

      <body> 

       <div id="box"> 
         <%= form_for(resource, :as => resource_name, :url => user_password_path(resource_name), :html => { :method => :post }) do |f| %> 
          <%= devise_error_messages! %> 

           <%= f.text_field :id,:name => "user[login]", :placeholder => "Username or Email"%> 

           <input name="commit" type="submit" name="" value="Submit" /> 
         <% end %> 
       </div> 
      </body> 
+0

你可以發佈你的路線嗎? (或至少只是設計和用戶部分),還有重置密碼電子郵件模板中的路徑幫助程序 – 2012-07-20 16:13:49

+0

對於後期更新,抱歉,不在城裏。這是我認爲你想要的,如果你想要更多,請告訴我。謝謝。 – Vasseurth 2012-07-25 02:10:25

+0

對不起,我認爲這是你的重置密碼電子郵件中的一個不好的鏈接,你可以發佈你的config.reset_password_keys(在設計配置文件中)和你的重置密碼錶 – 2012-07-25 02:23:56

回答

0

如果我正確理解你的話,似乎你需要編輯你的視圖或設計init文件=> config/initializers/devise.rb

你可以通過運行設計生成器來編輯你的視圖 rails generate devise:views用戶

我希望幫助

0

我們有一個類似的問題。對我們來說,當我們編輯我們自己的帳戶時,Devise正在將我們註銷。我們使用sign_in()設計助手,結束了使用此代碼:

user_controller

高清更新

# need to know if user is changing their own password for re-sign in purposes. 
is_current_user = (@user == current_user) 

password_change = !params[:user][:password].empty? 
if (password_change) 
    @user.update_with_password(params[:user]) 
else 
    @user.update_without_password(params[:user]) 
end 

if is_current_user # Devise signs us out, so... 
    sign_in(@user, :bypass => true) 
end 


@user.has_temp_password = false 
@user.save! 

if is_current_user 
    redirect_to root_path, notice: 'Your account was successfully updated.' 
else 
    redirect_to users_path, notice: 'The user was successfully updated.' 
end 

0

嘗試改變形式的URL

:url => password_path(resource_name) 
相關問題