BTW: I know I can add a handcrafted field for my comment in the transition form tag, and then pick it up manually in the controller and make it an instance variable.
Would this be the "right way" to do something like this, or does anyone have any suggestions on how to do this more elegantly? Regards, Ronny On Aug 2, 8:19 am, Spiralis <[email protected]> wrote: > Thanks, but that is not the problem. I know transitions well and its > "in my fingertips" so to speak. > > However. I cannot use :params => [:comment], since comment is not a > part of the model. The comment field I want to show is an ad-hoc > field, a placeholder for the user to add a comment, which I can handle > in the block after the transition: > > Something like: > > transition :foo, { :work=> :work } , :params > =>[:comment], :available_to => :user do |record| > c = Comment.new > c.body = record.comment > record.comments << c > record.save! > end > > In the :work state allow a transition that keeps state in :work, but > which allows the user to enter a comment that will be saved in a child- > relation of the model. > > I *could* add a comment-field to the model and just use it to get the > form displayed and then never really use the field in the database, > but that *really* feels like a bad hack... > > On 2 Aug, 07:33, storitel <[email protected]> wrote: > > > not sure if I can help fully, but here goes - > > > Chapter 6 ofhttp://hobocentral.net/books/hobo-at-work.pdfdescribes > > how lifecycles work. > > > to put up a form for a comment, the transition definition should be > > something like... > > > transition :foo, { :start => :finish } , :params => > > [:comment], :available_to => :user > > > normally :comment would be a field in this model, and by default hobo > > makes a <foo-page> with a <foo-form> which you can use or override. > > > to update another model during the transition, you need to add code > > for the transition in your controller, something like > > > def do_foo > > do_transition_action :foo do > > # code for updating your other model goes here... > > end > > end > > > i hope this helps > > paul > > > On Aug 1, 11:45 am, Spiralis <[email protected]> wrote: > > > > I have a feeling that I have read something about this earlier, but > > > cannot seem to find the information anywhere. > > > > I have a model that is using states and transitions. Now, when certain > > > transitions take place I need the user to supply a comment. This > > > comment is not the same model, and I cannot seem to figure out how to > > > include it. After transition is submitted this comment should also be > > > persisted. > > > > I also have a couple of places where I consider adding view-only > > > fields to the transition. Fields that are not to be persisted, but > > > used as logics in the transition block. > > > > Regards, > > > Ronny > > -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
