1

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?

Ashan Priyadarshana
  • 3,119
  • 3
  • 29
  • 34

1 Answers1

0

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.

Ashan Priyadarshana
  • 3,119
  • 3
  • 29
  • 34
  • I'm having the same problem. BUT...I can't rename the state name in this legacy system. I'm getting " WARN -- : WorkOrder: overriding method 'invalid?'! – David Hempy Aug 16 '18 at 19:57