Ruby on rails 注册失败后设计重定向到错误路径

Ruby on rails 注册失败后设计重定向到错误路径,ruby-on-rails,devise,Ruby On Rails,Devise,我为我的Rails应用程序设置了Desive,到目前为止一切都很好。我唯一的问题是,design在注册失败后重定向到错误的路径 这是测试时错误的样子: Failures: 1) Register with wrong credentials Failure/Error: expect(page.current_path).to eq new_user_registration_path expected: "/register" got: "/" 我的测试如下所

我为我的Rails应用程序设置了Desive,到目前为止一切都很好。我唯一的问题是,design在注册失败后重定向到错误的路径

这是测试时错误的样子:

Failures:

1) Register with wrong credentials
   Failure/Error: expect(page.current_path).to eq new_user_registration_path

   expected: "/register"
        got: "/"
我的测试如下所示:

feature 'Register' do
   scenario 'with wrong credentials' do
      visit new_user_registration_path
      fill_in 'First Name', with: ''
      fill_in 'Email', with: ''
      fill_in 'Password', with: ''
      fill_in 'Confirm Password', with: '...'
      click_on 'Register'

      expect(page.current_path).to eq new_user_registration_path
      expect(page).to have_content 'errors'
   end
end
以下是我的路线:

devise_for :users,
           path: '/', 
           path_names: { sign_in: 'log_in', sign_out: 'log_out', sign_up: 'register'},
           controllers: { registrations: 'registrations'}
我试图覆盖前面提到的
设计/注册#创建
,但最终丢失了默认错误提示:

def create
   build_resource(sign_up_params)
   resource.save

   yield resource if block_given?
   if resource.persisted?
      if resource.active_for_authentication?
         set_flash_message :notice, :signed_up if is_flashing_format?
         sign_up(resource_name, resource)
         respond_with resource, location: after_sign_up_path_for(resource)
      else
         set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
         expire_data_after_sign_in!
         respond_with resource, location: after_inactive_sign_up_path_for(resource)
      end
   else
      clean_up_passwords resource
      # instead of
      # respond_with resources
      # I wrote: 
      redirect_to new_user_registration_path
   end
end
我正在使用:
Ruby 2.2.0
Rails 4.2.0
设计3.4.1
,尝试改变

devise_for :users,
           path: '/', 
           path_names: { sign_in: 'log_in', sign_out: 'log_out', sign_up: 'register'},
           controllers: { registrations: 'registrations'}

注意,我删除了
控制器:{registrations:'registrations'}
'/'


我认为
path:'/'
是问题的根源

我按照您的建议更改了
path:'/'
,但我无法删除
控制器:{registrations:'registrations'}
,因为我正在
registrations\u控制器中重写一些其他内容。错误仍然存在。
devise_for :users,
               path: '', 
               path_names: { sign_in: 'log_in', sign_out: 'log_out', sign_up: 'register'}