On 1 Apr 2011, at 23:22, John Merlino <[email protected]> wrote:

> 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

> 
>    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:
> 
> http://www.simonecarletti.com/blog/2009/09/inside-ruby-on-rails-extract_options-from-arrays/
> 
> 
> Thanks for response
> 
> -- 
> Posted via http://www.ruby-forum.com/.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to