README.md in rails_state_machine-2.2.0 vs README.md in rails_state_machine-3.0.0
- old
+ new
@@ -54,12 +54,12 @@
- `<state_name>?` to find out if this is the current state.
- `<event_name>` call an event and transition into a new state. The record will be `save`d, if valid.
- `<event_name>!` call an event and transition into a new state. Calls `save!` to save the record.
- `may_<event_name>?` to find out if an event transition could be taken. Note that this will not validate if the model is valid afterwards.
-- `state_event=` to take a state event, but not save yet. Commonly used for forms where the controller takes a "state_event" param and saves.
-- `state_event` to get the name of the event that will be called
+- `<state_name>_event=` to set the event the record tries to call on save. If the event is invalid, an `:invalid` error on the `<state_name>_event` is set. Commonly used for forms where the controller takes a "<state_name>_event" param and saves.
+- `<state_name>_event` to get the name of the event that will be called
Should you ever need to query the state machine for its states or events, it is accessible via `state_machine` class or instance methods on the model. See [`state_machine.rb`](https://github.com/makandra/rails_state_machine/blob/master/lib/rails_state_machine/state_machine.rb) for a list of available methods. This is mostly helpful in tests.
If you want an event to be available for a different edge in your graph, you may define multiple `transitions` per event:
@@ -125,9 +125,14 @@
state_machine :review_state, prefix: 'some_prefix' do
# ...
end
```
+Note: The `prefix` option is designed to apply only to constants and state methods **defined by the gem**.
+
+**State event names** are manually defined by the developer and thus not altered even if the `prefix`
+option is used. It's advised to review them regarding potential naming collision and clarity when
+ introducing the `prefix` method.
## Taking multiple transitions
You can safely take a second transition inside an after_save callback. All relevant
callbacks will be run.