Tuesday, August 10, 2010

Rails 3 doesn't like auto_link href_options

Even though the Rails doc indicates one should be able to do something like this:
auto_link(simple_format(h(text)), :href_options => { :class => 'auto-link' })
it doesn't work. looking at the Rails code in text_helper.rb, auto_link is only looking for options[:html], so :href => {} just gets ignored. one actually needs to do this:
auto_link(simple_format(h(text)), :html => {:class => 'auto-link'})
and now it works fine.

No comments:

Post a Comment