documentation and other quick questions

3 views
Skip to first unread message

epoch

unread,
May 10, 2009, 9:08:29 AM5/10/09
to state-fu
Hi David,

First off, thanks for sharing your gem. I've looking for a workflow
plugin for rails and bump into yours. Got a few questions after taking
a quick look.

1. Has state-fu been used in any production app yet? Is it stable
enough for used in production? Since the version number is pretty low.

2. I notice you recently gave a presentation on state-fu in Sydney,
found out too late. Is there any slides if you don't mind sharing? :-)

3. Is there any guidelines when storing the status in the database? I
tried storing a status_id integer field in my model that points to a
lookup table of the actually status names, seems to work fine. But I'm
not what is the used of this call 'object.status.state'

Thanks.
Daniel

David Lee

unread,
May 21, 2009, 7:37:04 AM5/21/09
to state-fu
Hi Daniel,

Thanks for taking the time to post.

1. Not yet in production, no. I am using its predecessor in production
however, and StateFu is far better written and tested ;) I am using it
heavily in well-tested projects under development, and I'm fairly
comfortable with its stability, but there may be some minor bugs to
iron out in the wild. That said, if you hit any, I'll attempt to track
them down & fix them as quickly as possible.

2. Actually, that was cancelled due to the unfortunate coincidence of
the newly-on-Tuesday meetup with Dylan Moran's appearance at the state
theatre. I do intend to give a presentation (or a few shorter ones) on
StateFu though, and I'll definitely make the slides available on the
project site - it may have to wait a little for current projects
though.

3. StateFu looks for the appropriate status field, and if it doesn't
find one uses an attribute persister. Eg:

class Foo
machine do
# looks for database column "state_fu_field"
end

machine(:bar)
# looks for database column "bar_field"
end

machine(:status, :field_name => :status)
# looks for database column "status"
end
end

4. Sorry about the delay in responding - haven't checked this email
address in a while, and when I do it's swamped ;o .. I'll see about
joining the group with one of my primary addresses.

cheers,
David

Spint

unread,
May 27, 2009, 7:02:19 AM5/27/09
to state-fu
Hello,

I'm playing around with your library, it looks very promising!
A quick question:
When an event is fired and state changes, the ActiveRecord object is
not saved to the DB,
you only do write_attribute(field, value) for AR persistence.
Why not save the changed status immediately to the DB (since you are
using bang! methods)?
Is there an easy way to force this behaviour (apart from using the
'accepted' hook on every status)

Thanks,

Stijn

epoch

unread,
May 31, 2009, 8:03:45 AM5/31/09
to state-fu
I think there's good reason to not save it straight away, but it would
be nice if we can easily force instant save if we need to.

Side note, I haven't read much of the code but I read somewhere that
write_attribute is deprecated in the latest version of rails? Is this
the same one we're talking about here?

Cheers,
Daniel

David Lee

unread,
Jun 3, 2009, 12:17:01 AM6/3/09
to stat...@googlegroups.com
Hi Stjin,

I intentionally didn't have it save! on each transition - there are use cases where I wouldn't want it to save automatically. But you're correct, you can easily add such behaviour via:

class Foo
  machine do
    # define states here ...

    states do
       accepted { save! }
    end
  end
end

Perhaps it does warrant it's own configuration option in the machine's options though, so you could simply declare

machine :autosave => true do
  # ...
end

What do you think?

cheers,
David
--
cheers,
David Lee

David Lee

unread,
Jun 3, 2009, 12:18:38 AM6/3/09
to stat...@googlegroups.com
http://apidock.com/rails/ActiveRecord/Base/write_attribute

Oh! you're correct. Thanks for the heads up. I'll look into this.
--
cheers,
David Lee

Spint

unread,
Jun 3, 2009, 5:36:56 AM6/3/09
to state-fu
Hi David,

There is also http://apidock.com/rails/ActiveRecord/AttributeMethods/write_attribute
which is not deprecated.

I've used acts_as_state_machine before where the changes are saved
automatically,
I would very much like the :autosave option in state_fu !

Regards,

Stijn

Spint

unread,
Jun 3, 2009, 5:50:26 AM6/3/09
to state-fu
Small correction here, it should be:
states do
accepted {object.save!}
end

I guess this is pretty clean, no hurries for the autosave option ;-)

Stijn
Reply all
Reply to author
Forward
0 new messages