Johan Bruning
unread,Jan 4, 2012, 8:20:01 AM1/4/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to PluginAWeek: Talk
I've just started using state_machine gem and it has already cleaned
up a lot of my code. I do however need to do 1 specific thing and
can't figure out from the README if/how this can be done.
All the code will be used in a Rails 3 app.
Let's say I have an article model which looks something like this:
state_machine :state, :initial => :new do
event :submit_for_approval do
transition [:new, :declined] => :pending
end
event :decline do
transition [:pending] => :declined
end
event :approve do
transition [:pending, :declined] => :published
end
end
This will give me the following methods (among others):
submit_for_approval, approve and decline.
Let's say I would like to keep a log of whoever performed these
actions on the given article.
I know there is something called state_machine-audit_trail, however
this only logs the changes.
I would like to pass in the invoker of the change in the
submit_for_approval, approve and decline methods. How can I achieve
this ?
If this is not possible or considered a bad practice what would you
suggest ?