Forum: Ruby on Rails (eval):1: syntax error, unexpected $undefined

1d4a45a695b48edc70359ca6d015e2f4?d=identicon&s=25 John Merlino (johnmerlino)
on 2012-05-02 03:55
(Received via mailing list)
On rails 3 and ruby 1.9.2, I get this error:

(eval):1: syntax error, unexpected $undefined
$#<MenuBuilder:0x007fd9360719a0> = #<MENUBUILDER:0X007FD9360719A0>
 ^

Not sure where to start with this. Everything looks fine to me:

#_main_menu.html.haml

#main-menu
  = menu do |m|
    = m.submenu "Products" do
      = m.item "Products", Product

#builders_helper.rb
module BuildersHelper
  def menu(options = {}, &block)
    MenuBuilder.new(self).root(options, &block)
  end
end

#menu_builder.rb

class MenuBuilder
  attr_accessor :template

  def initialize(template)
    @template = template
  end

  def root(options, &block)
    options[:class] = "jd_menu jd_menu_slate ui-corner-all"
    content_tag :ul, capture(self, &block), options
  end

  def item(title, url, options = {})
    content_tag :li, options do
      url = ajax_route(url) unless String === url
      url = dash_path + url if url.starts_with?("#")
      link_to title, url
    end
  end

  def submenu(title, options = {}, &block)
    content_tag :li do
      content_tag(:h6, title.t) +
      content_tag(:ul, capture(self, &block), :class => "ui-corner-
all")
    end
  end
end

It fails on this line for some reason:

    content_tag :ul, capture(self, &block), options

thnanks for response
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.