Advertisement
Guest User

Untitled

a guest
May 5th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. class CheckoutsController < ApplicationController
  2. ...
  3.  
  4. def create
  5. @checkout = @item.checkouts.build(checkout_params)
  6. respond_to do |format|
  7. if @checkout.save
  8. if @checkout.reservation == true
  9. @checkout.create_activity :reservation, options = { owner: Person.find(@checkout.checked_out_by), recipient: @item, approved_by_id: @user.id }
  10. else
  11. @checkout.create_activity :create, options = { owner: Person.find(@checkout.checked_out_by), recipient: @item, approved_by_id: @user.id }
  12. end
  13. format.html { redirect_to checkouts_path, notice: 'Checkout was successfully created.' }
  14. format.json { render json: @checkout, status: :created, location: @checkout }
  15. else
  16. format.html { render :new }
  17. format.json { render json: @checkout.errors, status: :unprocessable_entity }
  18. end
  19. end
  20.  
  21. ...
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement