2012-07-20 32 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) 
相关问题