Hey Frank, state_machine actually provides support for executing events using a standard REST interface. Rather than calling the event method directly (such as "release!"), you can set an the machine's event attribute like so:
station.state_event = 'release' station.save! Any event that gets set in "state_event" will be validated and fired when the record is saved. There's a full example (model, controller, and views) of this here: http://github.com/pluginaweek/state_machine/tree/master/examples/rails-rest Hope this helps! -Aaron On May 17, 10:50 pm, "frankjmat...@gmail.com" <frankjmat...@gmail.com> wrote: > the example i'm making uses state_machine because it's part of my > current setup but this isnt a state_machine specific problem. > > i have a model called Station. it's an abstract concept for "an area > in which work is performed"... when i'm using the app the Stations > could be anything from "simulation terminal A" to "the lathe in > building C"... > > each station has various properties (one of which is conveniently > "state") and i would like to use buttons on my form (or links if it > can be done in an xss safe way) to immediately change one of those > properties... one button for example may be "release to floor" which > when clicked would - in a non restful app - call the "release" action > on the station controller. the release action would then take the > station and call "release!" on it... however i want to accomplish this > using standard actions. > > just using a text box and "saving" the record doesn't automatically > fire the state-changing events (which i think is a good thing) AND > that type of structure does not relate to my problem in a convenient > way... there's a handful of cases where i just want to have a few > buttons peppered in my form that when clicked, perform a direct action > on my object without having to "invent" a bunch of non-standard > actions.. > > any tips? > thank you much, > - FJM > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.