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:
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment