In a layout, I''d like to write something like
<% if has_format?(:foo) -%>
<%= link_to ''Foo version'', :format => :foo %>
<% end %>
Grabbing into protected method territory, I can even define a suitable
helper method
def has_format?(format)
controller.send(:collect_mimes_from_class_level).include?(format)
end
(see action_controller/metal/mime_responds.rb)
I''d much rather have an official method, say
ActionController::MimeResponds#responds_to?(format), and a helper method
#has_format?(format) defined in terms of it. As the name #responds_to?
is dangerously close to #respond_to?, #responds_to_format? may be safer,
if less pretty. Also, it might be a good idea for
#collect_mimes_from_class_level to memoize its result.
Is there any reason against this? A better way?
Michael
--
Michael Schuerig
mailto:michael@schuerig.de
http://www.schuerig.de/michael/
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.