Skip to content

Commit

Permalink
Clarify README instructions for ActiveRecord
Browse files Browse the repository at this point in the history
* If you're using the ActiveRecord adapter, your transition class
should `include Statesman::Adapters::ActiveRecordTransition`.
* If you're using a PostgreSQL JSON column to store metadata, you
won't be able to
`include Statesman::Adapters::ActiveRecordTransition` as there is
an incompatability (which we'll aim to resolve soon, see #309).
Without this module, if you want to customise your transition
class's "updated timestamp column", you will need to define
`.updated_timestamp_column` yourself.
  • Loading branch information
Tim Rogers committed Feb 14, 2018
1 parent 0a2ed03 commit 42cdd84
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Order.not_in_state(:checking_out) # => [#<Order id: "123">]

By default Statesman stores transition history in memory only. It can be
persisted by configuring Statesman to use a different adapter. For example,
ActiveRecord within Rails:
for ActiveRecord within Rails:

`config/initializers/statesman.rb`:

Expand All @@ -137,6 +137,10 @@ Generate the transition model:
$ rails g statesman:active_record_transition Order OrderTransition
```

Your transition class should
`include Statesman::Adapters::ActiveRecordTransition` if you're using the
ActiveRecord adapter.

If you're using the ActiveRecord adapter and decide not to include the default
`updated_at` column in your transition table, you'll need to configure the
`updated_timestamp_column` option on the transition class, setting it to another column
Expand Down Expand Up @@ -178,8 +182,12 @@ or 5. To do that
t.json :metadata, default: {}
```

* Remove `include Statesman::Adapters::ActiveRecordTransition` statement from your
transition model
* Remove the `include Statesman::Adapters::ActiveRecordTransition` statement from
your transition model. (If you want to customise your transition class's "updated
timestamp column", as described above, you should define a
`.updated_timestamp_column` method on your class and return the name of the column
as a symbol, or `nil` if you don't want to record an updated timestamp on
transitions.)

## Configuration

Expand Down

0 comments on commit 42cdd84

Please sign in to comment.