Skip to content

Instantly share code, notes, and snippets.

@fcy
Forked from rodrigopinto/refactory.rb
Created January 13, 2012 20:03
Show Gist options
  • Select an option

  • Save fcy/1608422 to your computer and use it in GitHub Desktop.

Select an option

Save fcy/1608422 to your computer and use it in GitHub Desktop.
# encoding: utf-8
class OperationsController < ApplicationController
respond_to :json
rescue_from ActiveRecord::RecordNotFound, :with => :not_found
def show
operation = Operation.find(params[:id])
respond_with operation
end
def create
app = App.find_by_app_key!(params[:app_key])
operation = app.new_operation(params[:operation])
operation.save
respond_with operation
end
private
def not_found(exception = nil)
response = {error: { :message => exception.message, :request => request.path }}
render json: response, status: :not_found
end
end
@fcy
Copy link
Copy Markdown
Author

fcy commented Jan 17, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment