Forum: Ruby on Rails Custom MIME type syntax

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel S. (Guest)
on 2006-12-31 01:42
(Received via mailing list)
Hello there,

I'm new here, and so may not have be aware of any previous discusion on
this particular topic, but the lack of results when googling has led me
to believe there has been none.

Currently, the custom MIME type sytax is as follows:

  respond_to do |format|
    format.xml do
      # ...
    end

    format.js do
      # ...
    end
  end

What I do not understand is why the following syntax should not be used
instead:

  case format
  when :xml
    # ...
  when :js
    # ...
  end

This would mean defining a #format method that returned the name of the
negotiated content type.

Thoughts?
This topic is locked and can not be replied to.