ruote-web: could @workitem.fields_hash['params'] ever be nil?

0 views
Skip to first unread message

Arjan van Bentem

unread,
May 5, 2008, 5:24:11 AM5/5/08
to openwfe...@googlegroups.com

 

Is there a reason why @workitem.fields_hash['params'] could ever be nil in ruote-web? I assume not, but if so, then WorkitemHelper:: find_partial needs a minor patch.

 

Why do I ask?

 

While experimenting with some custom forms I forgot to add hidden fields to preserve the workflow parameters. This basically resulted in the field ‘params’ to be removed (as many other fields), which is a problem in WorkitemHelper:: find_partial which uses

 

    128:   activity = wi_fields['params']['activity']

 

Of course, one can easily add “if wi_fields['params']” or whatever, but on the other hand: the unexpected nil saved me from a lot of trouble at a later moment... :-)

 

http://github.com/jmettraux/ruote-web/tree/1c6b31fdb1ff24d181ab3724401ff79fe2e6ec19/app/helpers/workitem_helper.rb#L128

 

Cheers,

Arjan.

-- John, thanks for adding ${fv:..} and ${vf:..} !

 

John Mettraux

unread,
May 5, 2008, 5:47:05 AM5/5/08
to openwfe...@googlegroups.com
On Mon, May 5, 2008 at 6:24 PM, Arjan van Bentem
<Arjan.v...@bidnetwork.org> wrote:
>
> Is there a reason why @workitem.fields_hash['params'] could ever be nil in
> ruote-web? I assume not, but if so, then WorkitemHelper:: find_partial needs
> a minor patch.
>
> 128: activity = wi_fields['params']['activity']

What about something like

---8<---
class OpenWFE::Extras::Workitem
def params
self.field('params') || {}
end
end
--->8---

?

It's true that having it break and complain can save time. (Hence not
sure about adding).


> http://github.com/jmettraux/ruote-web/tree/1c6b31fdb1ff24d181ab3724401ff79fe2e6ec19/app/helpers/workitem_helper.rb#L128

This #Lxxx trick is neat, where did you learn about it ?


> -- John, thanks for adding ${fv:..} and ${vf:..} !

You're welcome !


Best regards,

--
John Mettraux - http://jmettraux.wordpress.com

Arjan van Bentem

unread,
May 5, 2008, 5:52:44 AM5/5/08
to openwfe...@googlegroups.com

> not sure about adding

So I assume that 'params' should indeed never be nil?

Apart from having a default or not: a method "params" might be nice
indeed, although then one might not expect "fields" to return those
params as well -- so maybe adding it would be confusing...


> This #Lxxx trick is neat, where did you learn about it ?

Errr, I just clicked on the line number in the normal view, and there it
was :-)

Arjan.


John Mettraux

unread,
May 5, 2008, 6:00:49 AM5/5/08
to openwfe...@googlegroups.com
On Mon, May 5, 2008 at 6:52 PM, Arjan van Bentem
<Arjan.v...@bidnetwork.org> wrote:
>
>
> > not sure about adding
>
> So I assume that 'params' should indeed never be nil?

Well, let's say that ruote-web, out of the box, assumes it will never
be nil. Please "monkey patch" Workitem (and the rest) at will in your
application. If the need becomes a pain, why not add the patch to the
core class, later.


> > This #Lxxx trick is neat, where did you learn about it ?
>
> Errr, I just clicked on the line number in the normal view, and there it
> was :-)

Priceless, though I couldn't get it to do ranges :-(


Cheers,

Reply all
Reply to author
Forward
0 new messages