Search code examples
ruby-on-railsrubystate-machinestates

Simple states in rails - state_machine


I'm looking for a recommendation for a simple way the change states of a model in rails. For example, I'd like the user to be able to change their jobs with a dropdown or ratio button to one of the following:

Job States

  1. Bids (initial state)
  2. In Progress
  3. Complete

Is there a simple way to write this in rails or is there a recommended gem? There are no transitions and the user should be able to change from one state to any of the other two in no particular order.

I looked into state_machine which seems a bit hefty for something like this.


Solution

  • It'll cost you $9, but Ryan Bates did a screencast about this very topic not too long ago: http://railscasts.com/episodes/392-a-tour-of-state-machines.

    Well worth watching.