0

我在我的 Rails 应用程序中使用设计。出于某种原因,当您单击“发送密码重置说明”按钮时,输入您的电子邮件后,它会将您带到一个带有此 url 的空白页面/users/password.user。我不知道它为什么这样做,也不知道如何改变它。

我不确切知道要发布什么代码,所以只需评论您希望我添加的摘录。谢谢。

作为记录,密码重置电子邮件和更改密码令牌完美运行,它只是这个奇怪的重定向(或缺少重定向)。

这些是路线:

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>
4

3 回答 3

0

尝试将表单中的 url 更改为

:url => password_path(resource_name)
于 2012-08-06T15:33:39.160 回答
0

我们遇到了类似的问题。对我们来说,事实证明,当我们编辑自己的帐户时,Devise 正在注销我们。我们使用了 sign_in() 设计助手并最终使用了以下代码:

用户控制器

定义更新

# 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

结尾

于 2012-08-05T01:13:13.047 回答
0

如果我理解正确,您似乎需要编辑您的视图或设计初始化文件 => config/initializers/devise.rb

您可以通过运行设计生成器来编辑视图 rails generate devise:views users

我希望这会有所帮助

于 2012-08-05T00:41:40.257 回答