Last active
August 29, 2015 14:17
-
-
Save rosiehoyem/8791c52b63b1af19688d to your computer and use it in GitHub Desktop.
Tracking Checkouts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CheckoutsController < ApplicationController | |
... | |
def create | |
@checkout = @item.checkouts.build(checkout_params) | |
respond_to do |format| | |
if @checkout.save | |
if @checkout.reservation == true | |
@checkout.create_activity :reservation, options = { owner: Person.find(@checkout.checked_out_by), recipient: @item, approved_by_id: @user.id } | |
else | |
@checkout.create_activity :create, options = { owner: Person.find(@checkout.checked_out_by), recipient: @item, approved_by_id: @user.id } | |
end | |
format.html { redirect_to checkouts_path, notice: 'Checkout was successfully created.' } | |
format.json { render json: @checkout, status: :created, location: @checkout } | |
else | |
format.html { render :new } | |
format.json { render json: @checkout.errors, status: :unprocessable_entity } | |
end | |
end | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Checkout < ActiveRecord::Base | |
include PublicActivity::Common | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment