Skip to content

Instantly share code, notes, and snippets.

@morgoth
Created Feb 11, 2011
Embed
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)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment