Questions tagged [aasm]

A library for adding finite state machines to Ruby classes.

Started as the acts_as_state_machine plugin but has evolved into a more generic library that no longer targets only ActiveRecord models.

Supports

  • States
  • Machines
  • Events
  • Transitions
132 questions
2
votes
2 answers

Background Video Processing with Rails

I am trying to get uploaded videos to be converted in the background, running windows. Some of what I am using: gem 'paperclip' gem 'delayed_job_active_record' gem 'ffmpeg' I have edited the registry to allow the ffmpeg command to be ran from…
Matthew
  • 35
  • 1
  • 8
1
vote
1 answer

How do I access old and new states in an aasm callback in rails?

I am new to both Ruby and Rails. I'm using AASM to put state machine behavior into a model class. Depending on the old and new states I want to handle the state change event in different ways. How do I either invoke the "after" callback with the…
1
vote
1 answer

Ruby add dynamic events using AASM

I've got a class in a program which is handling game states. I'm actually handling it with AASM so to create an event I have to use something like aasm_event :name ... inside the class. I need to be able to load other files who dynamically have to…
Cydonia7
  • 3,744
  • 2
  • 23
  • 32
1
vote
1 answer

Stopping event in AASM from after callback without raising exception

aasm column: :status, whiny_transitions: false do state :requested, initial: true state :approved event :approve, after: :after_approve do transitions from: :requested, to: :approved end end def after_approve raise "This is a…
Paul Odeon
  • 4,407
  • 1
  • 37
  • 37
1
vote
2 answers

AASM Gem broken by Rails 2.3.2?

Has anyone had any problems using the AASM state machine Gem with Rails 2.3.2? It was working fine for me but is now giving a NoMethodError: NoMethodError (undefined method `state' for #): …
John Topley
  • 113,588
  • 46
  • 195
  • 237
1
vote
2 answers

Why is my AASM state machine not triggered with Rails 7 Turbo patch links?

I just updated my Rails 6 app to Rails 7 and have problems updating my :patch and :delete links to Turbo. For example, in one of my views I have this link... link_to("Mark as sent", status_url(quote), :data => {:'turbo_method' => :patch}) ...…
Tintin81
  • 9,821
  • 20
  • 85
  • 178
1
vote
1 answer

Ruby AASM: trigger callbacks on model update

AASM callbacks are bypassed when updating model fields directly. This can be disabled by setting the no_direct_assignment flag, but this will break other integrations, such as a simple update via active_admin. Is there a way to allow model updates…
thisismydesign
  • 21,553
  • 9
  • 123
  • 126
1
vote
0 answers

Rails trigger AASM event on nested associations autosave

I have a parent and child model schema defined with each having its own AASM state machine class Project < ApplicationRecord has_many :tasks, autosave: true include AASM aasm do state :created, initial: true state :in_progress …
1
vote
0 answers

How to avoid defining state twice in aasm

I'm currently using the aasm gem and it works great. Is it possible to define state just once instead of twice like below? enum state: [:pending, :active, :inactive] aasm column: :state, enum: true do state :pending, :active, :inactive event…
vince
  • 2,374
  • 4
  • 23
  • 39
1
vote
0 answers

AASM state machine, can guards be skipped?

Is it possible to skip a guard in some instances? Kind of like running some_event_without_validation! except you're not skipping object validation, but transitions guards.
james
  • 3,989
  • 8
  • 47
  • 102
1
vote
0 answers

Rails AASM gem, how could you achieve substate?

It's my first time using AASM and I'm wondering how I might be able to achieve a substate implementation. Pure example as I'm learning through this. Let's say we're tracking the state of a patient as they move through a hospital. Here's an imaginary…
james
  • 3,989
  • 8
  • 47
  • 102
1
vote
1 answer

Implement a conditional state machine for a rails model

I have a rails model called Creative that implements a workflow using the aasm gem. Currently my model has just one workflow implemented in it. I have a business scenario that will require me to implement another workflow in the same model which…
Moiz Mansur
  • 180
  • 3
  • 13
1
vote
1 answer

Ruby State Machine with history, superstates, and logs/statistics?

Is there any state machine implementation for Ruby or Ruby on Rails that supports superstates, can keep track of past states (and edit them), and keep track of the time spent on each state? I've used aasm but it doesn't have all these features. I've…
Reed G. Law
  • 3,897
  • 1
  • 41
  • 78
1
vote
0 answers

Is there a way to use boolean field with aasm gem?

I am using boolean column is_locked with aasm gem but when I create new record then is_locked column has the 0 value as expected initial but when I try to lock it return true but value doesn't change in the column seems I am doing something…
1
vote
0 answers

Ruby AASM (Act as State Machine): processing a payment: combining a before callback with a guard

Let's assume a very simple Payment class like this: class Payment include AASM aasm do state :created state :paid state :refunded event :pay do transitions from :created, to :paid end end end So one would call…
sandre89
  • 5,218
  • 2
  • 43
  • 64
1 2 3
8 9