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
125 questions
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
  • 749
  • 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
  • 314
  • 2
  • 6
-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