Skip to content

Instantly share code, notes, and snippets.

@paul
Created January 7, 2009 21:16
Show Gist options
  • Save paul/44440 to your computer and use it in GitHub Desktop.
Save paul/44440 to your computer and use it in GitHub Desktop.
class Exceptions < Application
# handle RecordInvalid exceptions (406)
def record_invalid
@errors = request.exceptions.first.errors
rename_error_fields!
if content_type == :html
request.controller.send(request.params[:action])
else
render
end
end
end
class RegisteredTemplates < Application
def create
@registered_template = configuration.registered_templates.new(params[:registered_template])
if @registered_template.save
head(Created, :location => uri(:configuration_registered_template,
:configuration_id => configuration.id,
:id => @registered_template.id))
else
raise RecordInvalid.new(@registered_template.errors)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment