After adding aasm gem, application gives me error: wrong number of arguments (given 1, expected 0)

After adding aasm gem, application gives me error: wrong number of arguments (given 1, expected 0)

我的模特:

class Lead < ApplicationRecord

  include AASM

  aasm column: 'status' do
     state :new, initial: true
     state :valid

     event :submit do 
       transitions from: :new, to: :valid
     end 
     ...
  end
  ...

end

控制器:

class LeadsController < ApplicationController
  ...

  def create
  @lead = @leads.new lead_params 
  if @lead.save  
    flash[:success] = "Lead saved successfully"
    render 'show'
  end

  ...
end

尝试创建新潜在顾客时,出现错误 wrong number of arguments (given 1, expected 0)。这一切都发生在我加了aasmgem之后。可能是什么原因?

好不容易找到原因了。问题在于 AASM gem 的构建方式。这里我使用了 valid 作为状态。那就是问题所在。它似乎是 gem 中的保留键。将其重命名为另一个状态名称解决了问题。