Reputation: 3100
I'm using the auto_html Ruby gem for my Rails application to handle embedded links in a content field. I was originally using the standard <%= @object.content_html %>
method which works fine. However, this doesn't support the extra filters that may be needed. For example, it handles youtube links and image links, but not Soundcloud links. In order to handle Soundcloud links, I had to change the code to <%= auto_html(@object.content) {soundcloud} %>
as mentioned in a SO question Auto_html says block not supplied
However, this only now supports Soundcloud and it doesn't support the other filters (Youtube, images, links, etc). How can I support all of them, including soundcloud? Adding soundcloud to the object's model doesn't work:
auto_html_for :content do
html_escape
image
youtube(:width => 400, :height => 250, :autoplay => false)
link :target => "_blank", :rel => "nofollow"
soundcloud
simple_format
end
Upvotes: 1
Views: 261
Reputation: 3100
The problem was that I placed soundcloud after the link filter, so the application was rendering the soundcloud link as a normal link. Here's the final model:
auto_html_for :description do
html_escape
image
youtube(:width => 400, :height => 250, :autoplay => false)
soundcloud
link :target => "_blank", :rel => "nofollow"
simple_format
end
Upvotes: 1