# Proc objects in helpers

**URL:** <https://www.ruby-forum.com/t/proc-objects-in-helpers/119616>\
**Category:** Rails\
**Created:** [November 8, 2007, 3:58pm UTC](https://www.ruby-forum.com/t/proc-objects-in-helpers/119616 "2007-11-08T15:58:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![remcoh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@remcoh](https://www.ruby-forum.com/u/remcoh)\
**Post date:** [November 8, 2007, 3:58pm UTC](https://www.ruby-forum.com/t/proc-objects-in-helpers/119616/1 "2007-11-08T15:58:54Z")

</div>

Hi, i created a little helper which accepts two Procs/lambda’s for  
creating a form line which can provide “show” and “edit” functionality  
(so i only need one partial). in my view i can create a form line like  
this:

line(:label=\>“Naam”,:show=\>lambda{|r| r.name},:edit=\>lambda{text\_field  
“organisation”, “name”,:size=\>“50”})

this all works fine, but i am wondering: is this a smart thing to do?  
a \_form partial could contain many proc statements. can it lead to  
performance problems?

regards,  
remco

---

<div class="post-metadata">

**Author:** ![remcoh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@remcoh](https://www.ruby-forum.com/u/remcoh)\
**Post date:** [November 9, 2007, 9:45am UTC](https://www.ruby-forum.com/t/proc-objects-in-helpers/119616/2 "2007-11-09T09:45:01Z")

</div>

mmm, zero answers on my last three questions,  
i am starting to feel a little insecure, am i not formulating my  
questions correctly?

Remco Hh wrote:

> Hi, i created a little helper which accepts two Procs/lambda’s for  
> creating a form line which can provide “show” and “edit” functionality  
> (so i only need one partial). in my view i can create a form line like  
> this:
> 
> line(:label=\>“Naam”,:show=\>lambda{|r| r.name},:edit=\>lambda{text\_field  
> “organisation”, “name”,:size=\>“50”})
> 
> this all works fine, but i am wondering: is this a smart thing to do?  
> a \_form partial could contain many proc statements. can it lead to  
> performance problems?
> 
> regards,  
> remco

---

<div class="post-metadata">

**Author:** ![remcoh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@remcoh](https://www.ruby-forum.com/u/remcoh)\
**Post date:** [November 9, 2007, 8:43pm UTC](https://www.ruby-forum.com/t/proc-objects-in-helpers/119616/3 "2007-11-09T20:43:49Z")

</div>

On Nov 9, 2007, at 12:45 AM, Remco Hh wrote:

> > this all works fine, but i am wondering: is this a smart thing to do?  
> > a \_form partial could contain many proc statements. can it lead to  
> > performance problems?

If performance is your only concern, consider benchmarking. If you  
don’t plan to serve a gazillion pages, it probably won’t matter anyhow.

Just my $.02

---

<div class="post-metadata">

**Author:** ![remcoh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c37758/32.png) [@remcoh](https://www.ruby-forum.com/u/remcoh)\
**Post date:** [November 10, 2007, 9:03am UTC](https://www.ruby-forum.com/t/proc-objects-in-helpers/119616/4 "2007-11-10T09:03:29Z")

</div>

Steve R. wrote:

> On Nov 9, 2007, at 12:45 AM, Remco Hh wrote:
> 
> > > this all works fine, but i am wondering: is this a smart thing to do?  
> > > a \_form partial could contain many proc statements. can it lead to  
> > > performance problems?
> 
> If performance is your only concern, consider benchmarking. If you  
> don’t plan to serve a gazillion pages, it probably won’t matter anyhow.
> 
> Just my $.02

thanks steve,  
i thought of benchmarking, but i haven’t found a good method/tool for  
that  
i will look for it

remco
