ruby-on-railsstate-machineaasm

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


My model:

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

And the Controller:

class LeadsController < ApplicationController
  ...

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

  ...
end

When trying to create a new lead, it gives me error wrong number of arguments (given 1, expected 0). All this happened after I added aasm gem. What could be the reason?


Solution

  • Well found the reason after some hard work. Problem is with how AASM gem is built. Here I have used valid as a state. That's the problem. Seems like it's a reserved keywork in the gem. Renaming it to another state name solved the problem.