Questions tagged [acts-as-state-machine]

A plugin for adding finite state machines to Ruby classes. Evolved to [AASM] library.

12 questions
9
votes
4 answers

Persisting the state column on transition using rubyist-aasm (acts as state machine)

What is the best way to persist the object's state to the database on a transition using aasm? I had thought that this would happen automatically but this doesn't seem to be the case. (Edit: when I manually save the object, the state column does get…
Angela
  • 2,856
  • 1
  • 28
  • 37
5
votes
3 answers

aasm after callback with argument

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 …
Kyle Decot
  • 19,418
  • 35
  • 132
  • 245
4
votes
2 answers

How to add a default AASM state to existing model

I have an existing model in rails and I want to add AASM states to it. From my understanding, I should add a state column to my database through migrations first and then add some states to my rails model. How do I set a default state value…
Masha
  • 277
  • 1
  • 5
  • 17
3
votes
2 answers

Need clarification of Ruby state machine usage

My problem is that I have an application that gives a user the ability to define a workflow (states, transitions, events, etc.) and have my application know how it reacts (transitions) based on the users workflow. I have looked at several state…
Jon
  • 743
  • 8
  • 21
1
vote
1 answer

rails acts_as_state_machine no method error

I am getting this error while trying to follow a tutorial over here http://jimneath.org/2008/06/03/converting-videos-with-rails-converting-the-video.html I have the table called videos with field needed as tutorial says, but when trying to get the…
rmagnum2002
  • 10,824
  • 8
  • 45
  • 80
1
vote
1 answer

Acts as state machine loop

Is there any problem with adding a loop in the state machine for the rails plugin acts_as_state_machine? I'm trying to do something like this and is not working: state :not_sent state :sent event :test do transitions :from => :not_sent, :to =>…
Rafael
  • 604
  • 2
  • 6
  • 13
1
vote
3 answers

Tool to generate state transition diagram for acts_as_state_machine

The ruby gem acts_as_state_machine can be super helpful for modeling object lifecycles within a flexible finite state machine framework. But I often find myself wanting a visual representation of the state transitions. Is there a tool to generate an…
pje
  • 19,409
  • 9
  • 50
  • 67
1
vote
1 answer

Using acts_as_state_machine transition methods without saving

I want to be able to utilize the acts_as_state_machine transition methods which are auto-generated (e.g. event!).. but I don't want it to save right away. I'm updating the state as part of another set of operations, and so I don't want to be doing…
Salman Ansari
0
votes
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…
0
votes
1 answer

state_machine in rails 4 not proper initialize state column value

I am learning Rails and try to use state machine but i am not able to initialize value for state variable..can anyone help me class Primer < ActiveRecord::Base extend StateMachine::MacroMethods state_machine :initial => :data do event…
0
votes
1 answer

Creating a dynamic approval system in Rails

I am trying to figure out how to implement a dynamic approval system in Rails. The scenario is this: I have a model object (a document) which, when created, the user can assign an approval flow to. The document can be filled and submitted by a…
0
votes
1 answer

AASM: Verifying which object is moving a state forward

I'm using AASM from http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk In my example, I have a Karate dojo rails site. On the site, Teachers can manage the classes they instruct and move their students to the next logical belt. …
Abel
  • 2,017
  • 2
  • 18
  • 24