Created
December 10, 2012 02:05
-
-
Save ohayon/4247981 to your computer and use it in GitHub Desktop.
index
This file contains hidden or 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
def index | |
if params(:state) == used | |
@coupons = Coupon.all(params[:state]) | |
else | |
@coupons = Coupon.all | |
end | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render json: @coupons } | |
end | |
end |
def index
if params[:state] == "used"
@coupons = Coupon.where(:state => params[:state])
else
@coupons = Coupon.all
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @coupons }
end
end
You don't actually need the has_key? check in this case
lgtm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def index
if params.has_key?(:state) && params[:state] == "used"
@coupons = Coupon.where(:state => params[:state])
else
@coupons = Coupon.all
end
end