Helper with block compile error

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

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs