Skip to content

Instantly share code, notes, and snippets.

@spullen
Created August 22, 2013 12:52
Show Gist options
  • Save spullen/6306739 to your computer and use it in GitHub Desktop.
Save spullen/6306739 to your computer and use it in GitHub Desktop.
class ProtocolsController < ApplicationController
respond_to :json
before_action :set_protocol, only: [:show, :update, :destroy]
def index
respond_with @protocols = Protocol.ordered
end
def show
respond_with @protocol
end
def create
respond_with @protocol = Protocol.create(protocol_params)
end
def update
@protocol.update(protocol_params)
respond_with @protocol
end
def destroy
@protocol.destroy
respond_with @protocol
end
private
def protocol_params
params.require(:protocol).permit(:protocol_number, :title, :pi_name)
end
def set_protocol
@protocol = Protocol.find(params[:id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment