Returns a link tag that browsers and news readers can use to auto-detect an RSS or ATOM feed. The type can either be :rss (default) or :atom. Control the link options in url_for format using the url_options. You can modify the LINK tag itself in tag_options.
Options:
- :rel - Specify the relation of this link, defaults to "alternate"
- :type - Override the auto-generated mime type
- :title - Specify the title of the link, defaults to the type
Examples
auto_discovery_link_tag # => <link href="http://www.currenthost.com/controller/action" title="RSS" rel="alternate" type="application/rss+xml" /> auto_discovery_link_tag(:atom) # => <link href="http://www.currenthost.com/controller/action" title="ATOM" rel="alternate" type="application/atom+xml" /> auto_discovery_link_tag(:rss, {:action => "feed"}) # => <link href="http://www.currenthost.com/controller/feed" title="RSS" rel="alternate" type="application/rss+xml" /> auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"}) # => <link href="http://www.currenthost.com/controller/feed" title="My RSS" rel="alternate" type="application/rss+xml" /> auto_discovery_link_tag(:rss, {:controller => "news", :action => "feed"}) # => <link href="http://www.currenthost.com/news/feed" title="RSS" rel="alternate" type="application/rss+xml" /> auto_discovery_link_tag(:rss, "http://www.example.com/feed.rss", {:title => "Example RSS"}) # => <link href="http://www.example.com/feed" title="Example RSS" rel="alternate" type="application/rss+xml" />
Source Code
# File action_view/helpers/asset_tag_helper.rb, line 131 def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {}) tag( "link", "rel" => tag_options[:rel] || "alternate", "type" => tag_options[:type] || Mime::Type.lookup_by_extension(type.to_s).to_s, "title" => tag_options[:title] || type.to_s.upcase, "href" => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options ) end
<code/>and<pre/>for code samples.