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
0
votes
1 answer

How to skip a state in a state machine using AASM

I'm using the ruby AASM gem. Does anyone know what the right way to skip a state is? class Job # ... event :stage1_completed do if stage2_completed? transitions from: :stage1, :to => :stage3 else transitions from: :stage1,…
Daniel
  • 7,006
  • 7
  • 43
  • 49
0
votes
2 answers

How to test assm guard error with rspec?

I have a state machine with some guards to prevent special state transitions. In my spec, I'm trying to expect guard violation error like this: expect(violate_guard).to raise_exception As a result, I receive correct error in my spec…
Reza Owliaei
  • 3,293
  • 7
  • 35
  • 55
0
votes
1 answer

Grape Rails API causing AASM to run for GET requests

Here is my AASM aasm column: :status do state :pre_approval, initial: true state :pending state :opened state :closed event :approved do transitions from: :pre_approval, to: :pending, guard: :approved? end event…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
0 answers

Rails AASM (Acts as State Machine) on_transition callback blocks transition

My event signature is event :accepted do transitions :from => :created, :to => :scheduled, :on_transition => :driver_accepted_ride, :after => :notify_scheduled end on transition callback is def driver_accepted_ride( driver ) Rails.logger.debug…
deepwinter
  • 4,568
  • 2
  • 31
  • 37
0
votes
0 answers

using Acts as State Machine, how to set a specific time period for a given state?

given the below; aasm do state :available, :intitial => true state :presented state :invited event :present do transitions :from => :available, :to => :presented end event :invite do transitions :from => :presented, :to =>…
John
  • 1,246
  • 15
  • 34
0
votes
1 answer

How can I access a collection of acts_as_state_machine states for a particular rails model?

Is it possible to access the collection of states for the given model: class Conversation include AASM aasm_initial_state :unread aasm_state :unread aasm_state :read aasm_state :closed aasm_event :view do transitions :to => :read, :from =>…
rswolff
  • 3,258
  • 5
  • 28
  • 31
0
votes
1 answer

Multiple counter cache columns with aasm

I am looking for a way to cache the number of each state. I have done counter caching before, but is there a way to create multiple counter_cache columns for each state and keep them updated or should I look elsewhere for caching these…
Blake Chambers
  • 505
  • 1
  • 5
  • 14
0
votes
1 answer

How do you override :set_initial_state from AASM when testing with Factory Girl factories?

Update Answered below. In case the linked site disappears, you can use mocha to stub the initial state and prevent overwriting as in ... require 'mocha' class OrderTest < ActiveSupport::TestCase def setup …
Kevin Dewalt
  • 757
  • 9
  • 24
-1
votes
1 answer

AASM Callback right after creating and instance

so im using the aasm gem for the first time and im emulating a credit card transaction. The initial state is "Pending" and i need a callback that right after creating a transaction it checks if the amount of the transaction is bigger than the limit.…
-1
votes
2 answers

acts_as_state_machine helper method rails 6

i have a verified and unverified states in my booking model, how do i implement helper methods for my views? i would like something like this in my index views. <% @bookings.each do |booking| %> <%= link_to booking_path(booking) do %> …
Brian Ngeywo
  • 398
  • 1
  • 5
  • 10
-1
votes
1 answer

How to check if all records of an instance have one of many values from a list of values?

I'm looking for a solution for a complex query. Goal : I want to know if all record of an instance have a value, and do some action when all records of the instance have the same value. Order Model : has_many :items Columns : treated Item Model…
user10089436
-1
votes
1 answer

Ruby on rails AASM Change transition with button click

I want to change status on the view. model aasm :column => 'state' do state :activated, :initial => true state :desactivated event :to_desactivated do transitions :to => :desactivated, :from => :activated end event…
1 2 3
8
9