Created
March 2, 2014 19:08
-
-
Save dannymcc/9311891 to your computer and use it in GitHub Desktop.
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 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