Skip to content

Instantly share code, notes, and snippets.

@dannymcc
Created March 2, 2014 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannymcc/9311891 to your computer and use it in GitHub Desktop.
Save dannymcc/9311891 to your computer and use it in GitHub Desktop.
class VouchersController < ApplicationController
layout "widescreen"
def index
@vouchers = Voucher.search(params[:search], params[:page]).per_page(30)
respond_to do |format|
format.html {redirect_to(@vouchers[0]) if @vouchers.length == 1}
format.json { render json: @vouchers }
end
end
def show
@voucher = Voucher.find(params[:id])
end
def claim
@voucher = Voucher.find(params[:id])
@voucher.claim!
redirect_to vouchers_path, notice: "Voucher #{@voucher.code} claimed successfully"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment