{:class=>"pi stuff"} is not a symbol

Hey all,

I'm building a html helper.

My view looks like this:

          = item_view "title", @post.title, :class => 'stuff'

My helper looks like this:

  def format_item_data(data)     case data       when Class then ''       when School then school(data)       else data.to_s     end.to_s.html_safe   end

  def item_view(label, *args)     data = args.first     formatter = args.second     options = args.extract_options!     options[:class] = "pi #{options[:class]}".strip

    text = formatter ? send(formatter,data) : format_item_data(data)

    content_tag :div, options do       content_tag(:div, label, :class => "label") +       content_tag(:div, text, :class => "data")     end   end

I get the following error:

{:class=>"pi stuff"} is not a symbol

I'm not sure why its throwing this exception. I followed this tutorial that says I can pass a hash as part of the argument list:

Thanks for response

Have you got a field in your model called "class"? If so, I'd change that, as it's a reserved word, and will cause all sorts of confusion to Ruby.

Hey all,

I'm building a html helper.

My view looks like this:

         = item_view "title", @post.title, :class => 'stuff'

This means that args.second is your hash of options

def item_view(label, *args)    data = args.first    formatter = args.second

So here you set formatter to that hash

   options = args.extract_options!    options[:class] = "pi #{options[:class]}".strip

   text = formatter ? send(formatter,data) : format_item_data(data)

And here you're therefore using that hash as the first argument to send, which makes no sense. Did you mean to call extract_options earlier on?

Fred