Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2011 09:33
What would you like to do?
def respond_with(*resources, &block)
raise "In order to use respond_with, first you need to declare the formats your " <<
"controller responds to in the class level" if self.class.mimes_for_respond_to.empty?
if response = retrieve_response_from_mimes(&block)
options = resources.size == 1 ? {} : resources.extract_options!
resources = resources.size == 1 ? Array.wrap(resources.first) : resources
options.merge!(:default_response => response)
(options.delete(:responder) || self.class.responder).call(self, resources, options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment