I'm using the aasm (formerly acts_as_state_machine
) gem in my rails 4 application. I have something like this on my Post
model
...
aasm column: :state do
state :pending_approval, initial: true
state :active
state :pending_removal
event :accept_approval, :after => Proc.new { |user| binding.pry } do
transitions from: :pending_approval, to: :active
end
end
...
When I call @post.accept_approval!(:active, current_user)
and the after callback gets triggered, in my console I can inspect what user
is (that was passed into the Proc) and it's nil
!
What's going on here? What is the correct way to call this transition?