# Working with Blocks

**URL:** <https://www.ruby-forum.com/t/working-with-blocks/160426>\
**Category:** Rails\
**Created:** [February 16, 2009, 8:29am UTC](https://www.ruby-forum.com/t/working-with-blocks/160426 "2009-02-16T08:29:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 16, 2009, 8:29am UTC](https://www.ruby-forum.com/t/working-with-blocks/160426/1 "2009-02-16T08:29:26Z")

</div>

hey

I am able to do:

```
 block_func(x, y) do
  ....
 end

```

But if I try to do this:

```
 form.block_func(x, y) do
  ....
 end

```

I get an error like this:

```
  syntax error, unexpected ')'
  @output_buffer.concat " "; @output_buffer.concat

```

(( form.block\_func(x, y) do ).to\_s);  
@output\_buffer.concat “\n”

Any ideas?

thanks

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 16, 2009, 9:09am UTC](https://www.ruby-forum.com/t/working-with-blocks/160426/2 "2009-02-16T09:09:48Z")

</div>

I should mention that I am making these functions myself… to use in  
a view

Is there something I need to do to get the function working as a model  
method in a “do” block?

On Feb 16, 4:48 pm, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 16, 2009, 12:15pm UTC](https://www.ruby-forum.com/t/working-with-blocks/160426/3 "2009-02-16T12:15:01Z")

</div>

On 16 Feb 2009, at 08:09, removed\_email\_address@domain.invalid wrote:

> I should mention that I am making these functions myself… to use in  
> a view
> 
> Is there something I need to do to get the function working as a model  
> method in a “do” block?

some more context would be useful - at a basic level you don’t need to  
anything in particular to do this (eg when you’re calling fields\_for  
on a form builder). You might have used \<%= when you should have used \<%

Fred
