So… a philosophical question about application organization and
Generally speaking, all my models represent tangible, model-ish
things. For such things, REST makes perfect sense to me, and the
indications for how to implement using REST with Rails are very clear.
However, there are lots of things that are not very tangible, and seem
to not be good REST candidates. For instance, if I have the
equivalent of a druid or wizard or whatever, where I am sequentially
collecting data necessary for some ultimate update, I would prefer to
have several different actions, one for each step, rather than include
state and checks for the same in a single action. Either way, though,
I am outside of the normal REST magic 7 actions. In this case, the
state is part of a single logical action that comprises several
physical (for lack of a better name) actions. The variables that I am
collecting along the way are in the session state.
I am not sure what is RESTful here or not.
The ultimate goal is to invoke a CREATE or UPDATE action at some point
that changes state in a model. Assuming I don’t care if I lose
anything along the way (dead druid?), then I need to use forms and
POST actions to get the data from my forms to Rails. Of course, I
shouldn’t do that, since POST’s are supposed to change things. But,
the thing I am changing is not really part of the target model yet…
see the issue?
Should I create a larger model that comprises a model for each state
of the collection process, and then read from all those records once I
am ready to do the ultimate update? Seems like having a model for
each part is overkill.
Or, I could implement a state field that indicates if a record is
“ready” or not. The first stage of the druid finds any records that
are available to be used for creating a new record (timed-out sessions
from previous attempts, records in a parallel, identical “buddy”
table, etc.) and allocates it for use, the final stage updates it and
removes it from the available pool by marking it as a full-fledged
member of the table. This seems better, but essentially solves the
problem by making the model “modal” (and illiterative!), which also
seems not so very RESTful.
I supposed the base questions are these:
* Is it bad to have actions other than the magic 7 for RESTful
* Either way, is there a way to organize them (subclassing,
proxies, etc.) that is considered clean? If so, what is it?
* How does organize multi-step behavior in a RESTful way? Has
this already been solved, and are there plugins for modal models or
wizard-like controllers that are considered RESTful?
I found acts_as_wizard, but it seems pretty old and is clearly not
Any ideas appreciated!