0
嗨,大家好, 我使用github和Rails 4.1.4的设计源。设计3.2.4使用设计/密码控制器中的更新方法“忘记我的密码”链接
我的Gemfile:
gem 'rails', '4.1.4'
gem 'devise', path: '../devise'
和我的色器件密码/ new.html.erb观点:
<%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), method: :put) do |f| %>
<%= f.input :email %>
<%= f.button :submit, t('.send_me_reset_password_instructions'
, :default => "Send me reset password instructions")
, class: 'btn-primary pull-right', method: "post" %>
<% end %>
我北医三院方法: “后” 来试试强制创建方法
My config/routes.rb:
devise_for :users, controllers:
{ omniauth_callbacks: "users/omniauth_callbacks" }, skip: :registrations
devise_scope :user do
resource :registration,
only: [:new, :create, :edit, :update],
path: 'users',
path_names: { new: 'sign_up' },
controller: 'devise/registrations',
as: :user_registration
end
条我的色器件路线:
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
设计生成html形式:
<form accept-charset="UTF-8" action="https://stackoverflow.com/users/password" class="simple_form new_user" id="new_user" method="post" novalidate="novalidate">
.....
</form>
但是,当我点击提交按钮,我送到控制器中的更新(PUT)方法。我想,我需要重定向到创建(POST)方法。
Started PUT "https://stackoverflow.com/users/password" for 127.0.0.1 at 2014-07-25 12:07:05 -0300
Processing by Devise::PasswordsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"gYiLxMKPSvCN5x6n5b0TtNyzTPcH1L3825Jp7NAdzs0=", "user"=> {"email"=>"[email protected]"}, "commit"=>"Enviar instruções para redefinição da senha"}
gem install awesome_print # <-- highly recommended
From: /home/carlos.ribeiro/code/devise/app/controllers/devise/passwords_controller.rb @ line 32 Devise::PasswordsController#update:
31: def update
=> 32: binding.pry
33: self.resource = resource_class.reset_password_by_token(resource_params)
34: yield resource if block_given?
35:
36: if resource.errors.empty?
37: resource.unlock_access! if unlockable?(resource)
38: flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
39: set_flash_message(:notice, flash_message) if is_flashing_format?
40: sign_in(resource_name, resource)
41: respond_with resource, location: after_resetting_password_path_for(resource)
42: else
43: respond_with resource
44: end
45: end
我在做什么错?
感谢= d
由于是创建方法,其发送给USET说明重置密码: 'DEF创建 binding.pry self.resource = resource_class.send_reset_password_instructions(resource_params) 产量资源如果block_given? 如果successfully_sent(资源) respond_with({},位置:after_sending_reset_password_instructions_path_for(RESOURCE_NAME))? 别的 respond_with(资源) 端 end' –
右流是PUT方法?当我输入忘记密码页面时,我在现场输入我的电子邮件并提交?谢谢 –
我下载了https://github.com/RailsApps/rails-devise,并进行了调试。正确的流程是致电#create –