# Helper with block compile error

**URL:** <https://www.ruby-forum.com/t/helper-with-block-compile-error/105264>\
**Category:** Rails\
**Created:** [May 28, 2007, 8:57am UTC](https://www.ruby-forum.com/t/helper-with-block-compile-error/105264 "2007-05-28T08:57:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [May 28, 2007, 8:57am UTC](https://www.ruby-forum.com/t/helper-with-block-compile-error/105264/1 "2007-05-28T08:57:37Z")

</div>

HI,  
i’m trying to write a helper that replaces link\_to\_remote that  
accepts a block but it gets a compile error in the template:  
I don’t know what I’m doing wrong… TIA

# application\_helper.rb

def link\_block\_to\_remote( options = {}, html\_options = {}, &block)  
concat(link\_to\_remote(capture(&block), options, html\_options),  
block.binding)  
end

# in template

```
       <% link_block_to_remote
           {:url => { :action => :start_login } },
           { :href => url_for( { :action => :start_login }), #

```

when degraded  
:class =\> “home-box home-box2”,  
:id =\> “home-login-container”} do %\>

# LOGIN
  

Already have an account?

  

LOG IN NOW

  
\<% end %\>
# the error I get is a compile error

compile error  
syntax error, unexpected tASSOC, expecting ‘}’  
\_erbout.concat " "; link\_block\_to\_remote { :url =\>  
{ :action =\> :start\_login } },  
^  
syntax error, unexpected ‘,’, expecting kEND  
\_erbout.concat " "; link\_block\_to\_remote { :url =\>  
{ :action =\> :start\_login } },

```
                 ^

```

syntax error, unexpected kDO, expecting kEND  
:id =\> “home-login-container”} do ;  
\_erbout.concat “\n”

# if i remove the html\_options from the call, and remove the braces,

it is ok

\<% link\_block\_to\_remote :url =\> { :action =\> :start\_login } do

---

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [May 29, 2007, 3:09am UTC](https://www.ruby-forum.com/t/helper-with-block-compile-error/105264/2 "2007-05-29T03:09:34Z")

</div>

yep that took care of it, thanks  
(my first helper using &block :))

---

<div class="post-metadata">

**Author:** ![johanatan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johanatan](https://www.ruby-forum.com/u/johanatan)\
**Post date:** [May 28, 2007, 11:37am UTC](https://www.ruby-forum.com/t/helper-with-block-compile-error/105264/3 "2007-05-28T11:37:51Z")

</div>

does it help if you use parenthesises around for  
link\_block\_to\_remote() ? (which by the way is good style)

```
       <% link_block_to_remote

```

(  
{:url =\> { :action =\> :start\_login } },  
{ :href =\> url\_for( { :action =\> :start\_login }), #when  
degraded  
:class =\> “home-box home-box2”,  
:id =\> “home-login-container”}  
) do %\>

# LOGIN
  

Already have an account?

  

LOG IN NOW

  
\<% end %\>

marcel
