在设计升级时错误的参数数量(2为1)

时间:2015-01-13 16:36:15

标签: ruby-on-rails devise ruby-on-rails-4.2

尝试从Rails 4.1升级到rails 4.2,并在此过程中设计从3.0到3.4(由于3.0的依赖性)

我有一个非常基本的控制器:

class BasicController < ActionController::Base
  #purposely not inherited from Application Controller to try and isolate the issue

  before_filter :authenticate_user!

  def index
  end

end

routes.rb包含:

get 'basic/index'

我对这个控制器的规范是:

#purposely not included spec_helper as I don't want to complicate things.
1.describe BasicController do
2.  it "should be able to get index" do
3.    @request.env['devise.mapping'] = Devise.mappings[:user]
4.    @current_user = FactoryGirl.create(:user)
5.    sign_in :user, @current_user #Also tried sign_in @current_user
6.    get :index
7.    response.should be_success
8.  end 
9.end

此规范错误ArgumentError: wrong number of arguments (2 for 1) #./spec/controllers/basic_controller_spec.rb:6

使用设计3.4.1和rails 4.2.0

如果我用简单的User.create(....)替换工厂女孩,则仍会出现错误。

为什么会发生这种情况的任何想法?

3 个答案:

答案 0 :(得分:0)

而不是signin :user, @current_user 使用

sign_in @current_user

答案 1 :(得分:0)

你是否偶然使用Squeel?如果是这样,1.2.2中存在一个问题,其中Rails 4.2导致此错误。更新到1.2.3已修复此错误。

具体而言,错误来自create_binds,他们修复了实施问题,请参阅https://github.com/activerecord-hackery/squeel/issues/352

答案 2 :(得分:0)

也许turbolinks gem是一个答案?

尝试升级或停用它。对我来说,这是错误的原因。请参阅:Why is there a wrong number of arguments error when using redirect_to in Rails 4.2?