Ruby on rails 设计电子邮件可以';不要在轨道4/5上为空

Ruby on rails 设计电子邮件可以';不要在轨道4/5上为空,ruby-on-rails,ruby-on-rails-4,devise,ruby-on-rails-5,devise-recoverable,Ruby On Rails,Ruby On Rails 4,Devise,Ruby On Rails 5,Devise Recoverable,routes.rb Given I am a registered user And I am not logged in When I visit "http://localhost:3000/member/password/edit?reset_password_token=BVE492WU1YqMp6nmxCX4" And I fill in "asdfasdf" in "user[:password] And I fill in "asdfasdf" in "user[:password

routes.rb

Given I am a registered user
And I am not logged in
When I visit "http://localhost:3000/member/password/edit?reset_password_token=BVE492WU1YqMp6nmxCX4"
And I fill in "asdfasdf" in "user[:password]
And I fill in "asdfasdf" in "user[:password_confirmation]
And I submit form
Then I see "Email can't be blank" -> which should be skipped
  devise_for :users,
             path: 'member',
             controllers: {registrations: 'member/registrations',
                           sessions: 'member/sessions',
                           passwords: 'member/passwords',
                           confirmations: 'member/confirmations',
                           unlocks: 'member/unlocks',
                           omniauth_callbacks: 'member/omniauth_callbacks'}

  devise_scope :user do
    match 'member/finish_signup/:id', to: 'member/registrations#finish_signup', via: [:get, :post], :as => :finish_signup
    match 'member/show_token', to: 'member/registrations#show_token', via: [:get, :post]
    # also tried without the following lines
    patch 'member/password' => 'member/passwords#update'
    put 'member/password' => 'member/passwords#update'
  end
    before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:sign_in, keys: [:email, :password])
    devise_parameter_sanitizer.permit(:account_update, keys: [:email, :password, :password_confirmation])
    # NONE of the both below change anything
    devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation])
    # this one does not work anymore
    # devise_parameter_sanitizer.for(:sign_up) do |u|
    #   u.permit(:email,:password,:password_confirmation)
    # end
  end
<form class="new_user" id="new_user" action="/member/password.user" accept-charset="UTF-8" method="post">

    <input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="patch">

    <input type="hidden" name="authenticity_token" value="Egh7QFhtHwcBVCuUgTDFnOF2C/g2Ql/sKeiuwjchjmpDh4JqyBPuLTaN9VT9iFFiP7JDxbp0+BeeA2QUSJWN3g==">

    <input type="hidden" value="BVE492WU1YqMp6nmxCX4" name="user[reset_password_token]" id="user_reset_password_token">

          <em>(8 characters minimum)</em><br>
      <input autofocus="autofocus" autocomplete="off" type="password" name="user[password]" id="user_password">

      <input autocomplete="off" type="password" name="user[password_confirmation]" id="user_password_confirmation">

      <input type="submit" name="commit" value="Change my password" data-disable-with="Change my password">
</form>
应用程序\u控制器.rb

Given I am a registered user
And I am not logged in
When I visit "http://localhost:3000/member/password/edit?reset_password_token=BVE492WU1YqMp6nmxCX4"
And I fill in "asdfasdf" in "user[:password]
And I fill in "asdfasdf" in "user[:password_confirmation]
And I submit form
Then I see "Email can't be blank" -> which should be skipped
  devise_for :users,
             path: 'member',
             controllers: {registrations: 'member/registrations',
                           sessions: 'member/sessions',
                           passwords: 'member/passwords',
                           confirmations: 'member/confirmations',
                           unlocks: 'member/unlocks',
                           omniauth_callbacks: 'member/omniauth_callbacks'}

  devise_scope :user do
    match 'member/finish_signup/:id', to: 'member/registrations#finish_signup', via: [:get, :post], :as => :finish_signup
    match 'member/show_token', to: 'member/registrations#show_token', via: [:get, :post]
    # also tried without the following lines
    patch 'member/password' => 'member/passwords#update'
    put 'member/password' => 'member/passwords#update'
  end
    before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:sign_in, keys: [:email, :password])
    devise_parameter_sanitizer.permit(:account_update, keys: [:email, :password, :password_confirmation])
    # NONE of the both below change anything
    devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation])
    # this one does not work anymore
    # devise_parameter_sanitizer.for(:sign_up) do |u|
    #   u.permit(:email,:password,:password_confirmation)
    # end
  end
<form class="new_user" id="new_user" action="/member/password.user" accept-charset="UTF-8" method="post">

    <input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="patch">

    <input type="hidden" name="authenticity_token" value="Egh7QFhtHwcBVCuUgTDFnOF2C/g2Ql/sKeiuwjchjmpDh4JqyBPuLTaN9VT9iFFiP7JDxbp0+BeeA2QUSJWN3g==">

    <input type="hidden" value="BVE492WU1YqMp6nmxCX4" name="user[reset_password_token]" id="user_reset_password_token">

          <em>(8 characters minimum)</em><br>
      <input autofocus="autofocus" autocomplete="off" type="password" name="user[password]" id="user_password">

      <input autocomplete="off" type="password" name="user[password_confirmation]" id="user_password_confirmation">

      <input type="submit" name="commit" value="Change my password" data-disable-with="Change my password">
</form>
密码/edit.html.erb

Given I am a registered user
And I am not logged in
When I visit "http://localhost:3000/member/password/edit?reset_password_token=BVE492WU1YqMp6nmxCX4"
And I fill in "asdfasdf" in "user[:password]
And I fill in "asdfasdf" in "user[:password_confirmation]
And I submit form
Then I see "Email can't be blank" -> which should be skipped
  devise_for :users,
             path: 'member',
             controllers: {registrations: 'member/registrations',
                           sessions: 'member/sessions',
                           passwords: 'member/passwords',
                           confirmations: 'member/confirmations',
                           unlocks: 'member/unlocks',
                           omniauth_callbacks: 'member/omniauth_callbacks'}

  devise_scope :user do
    match 'member/finish_signup/:id', to: 'member/registrations#finish_signup', via: [:get, :post], :as => :finish_signup
    match 'member/show_token', to: 'member/registrations#show_token', via: [:get, :post]
    # also tried without the following lines
    patch 'member/password' => 'member/passwords#update'
    put 'member/password' => 'member/passwords#update'
  end
    before_action :configure_permitted_parameters, if: :devise_controller?

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:sign_in, keys: [:email, :password])
    devise_parameter_sanitizer.permit(:account_update, keys: [:email, :password, :password_confirmation])
    # NONE of the both below change anything
    devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation])
    # this one does not work anymore
    # devise_parameter_sanitizer.for(:sign_up) do |u|
    #   u.permit(:email,:password,:password_confirmation)
    # end
  end
<form class="new_user" id="new_user" action="/member/password.user" accept-charset="UTF-8" method="post">

    <input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="patch">

    <input type="hidden" name="authenticity_token" value="Egh7QFhtHwcBVCuUgTDFnOF2C/g2Ql/sKeiuwjchjmpDh4JqyBPuLTaN9VT9iFFiP7JDxbp0+BeeA2QUSJWN3g==">

    <input type="hidden" value="BVE492WU1YqMp6nmxCX4" name="user[reset_password_token]" id="user_reset_password_token">

          <em>(8 characters minimum)</em><br>
      <input autofocus="autofocus" autocomplete="off" type="password" name="user[password]" id="user_password">

      <input autocomplete="off" type="password" name="user[password_confirmation]" id="user_password_confirmation">

      <input type="submit" name="commit" value="Change my password" data-disable-with="Change my password">
</form>
这是我提交填写的“/passwords/edit.html.erb”时的日志 ()

我认为
密码路径(资源名称)
的路由不正确。这让我想到了
member/passwords#create
,而不是
member/passwords#update
,这似乎是正确的

求你了,我怎样才能解决这个问题

.gemfile

Started GET "/member/password/edit?reset_password_token=[FILTERED]" for 127.0.0.1 at 2016-03-04 12:40:41 +0100
Processing by Member::PasswordsController#edit as HTML
  Parameters: {"reset_password_token"=>"[FILTERED]"}
DEPRECATION WARNING: [Devise] Changing the sanitized parameters through "Devise::ParameterSanitizer#for(sign_up) is deprecated and it will be removed from Devise 4.1.
Please use the `permit` method:

  devise_parameter_sanitizer.permit(:sign_up) do |user|
    # Your block here.
  end
 (called from deprecate_for_with_block at /Users/jan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/devise-4.0.0.rc1/lib/devise/parameter_sanitizer.rb:177)
  Rendered devise/shared/_links.html.erb (1.6ms)
  Rendered devise/passwords/edit.html.erb within layouts/application (3.5ms)
Completed 200 OK in 14ms (Views: 11.5ms)


Incoming Headers:
  Origin: http://localhost:3000
  Access-Control-Request-Method: 
  Access-Control-Request-Headers: 
Started POST "/member/password.user" for 127.0.0.1 at 2016-03-04 12:41:19 +0100
Processing by Member::PasswordsController#create as 
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"gmyAZDVZR4Z/OO3oa934MzNUwCFnzDSd7QLo6ZCoAnjT43lOpSe2rEjhMygXZWzN7ZCIHOv6k2Za6SI/7xwBzA==", "user"=>{"reset_password_token"=>"[FILTERED]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Change my password"}
Completed 406 Not Acceptable in 2ms



ActionController::UnknownFormat (ActionController::UnknownFormat):

responders (2.1.1) lib/action_controller/respond_with.rb:207:in `respond_with'
devise (4.0.0.rc1) app/controllers/devise/passwords_controller.rb:19:in `create'
/Users/jan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/rails-c901fad42cb4/actionpack/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
/Users/jan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/rails-c901fad42cb4/actionpack/lib/abstract_controller/base.rb:183:in `process_action'
/Users/jan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/rails-c901fad42cb4/actionpack/lib/action_controller/metal/rendering.rb:30:in `process_action'
/Users/jan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/rails-c901fad42cb4/actionpack/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/Users/jan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/rails-c901fad42cb4/activesupport/lib/active_support/callbacks.rb:126:in `call'
/Users/jan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/rails-c901fad42cb4/activesupport/lib/active_support/callbacks.rb:126:in `call'
/Users/jan/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/rails-c901fad42cb4/activesupport/lib/active_support/callbacks.rb:506:in `blo

更改为:
名称和路径的名称,并将方法更改为
post
。似乎它们没有在我的
设计范围中被覆盖

gem 'rails', github: "rails/rails"
gem 'active_model_serializers', github: "rails-api/active_model_serializers", branch: 'master'
gem 'mongoid', git: 'https://github.com/estolfo/mongoid.git', branch: 'MONGOID-4218-rails-5'
# api token authentication for devise
gem 'devise', "4.0.0.rc1"
# we can switch back when Rails 5, and Devise 4 is supported
gem 'simple_token_authentication', github: "consti/simple_token_authentication"

gem 'bootstrap_form'
gem 'omniauth'
gem 'omniauth-facebook'