Ah. I knew I had heard about this before. Excellent.

I never really got that far with Rails before I fell in love with
Hobo, so a little bit of rails knowledge here is appreciated ;)

Regards,
Ronny

On Aug 2, 7:31 pm, Matt Jones <[email protected]> wrote:
> On Mon, Aug 2, 2010 at 2: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...
>
> The standard Rails way to do this would be to use attr_accessor to
> create a "virtual" field on the model, then access it in a callback.
> I'd recommend you do the same, in the model:
>
> attr_accessor :comment, :type => :text
>
> Then the transition will be pretty much as you've described. You may
> want to use:
>
> Comment.user_new(acting_user)
>
> if comments have acting_user-powered stuff.
>
> --Matt Jones

-- 
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.

Reply via email to