Skip to content

Instantly share code, notes, and snippets.

Created February 26, 2012 17:22
Show Gist options
  • Save anonymous/1917840 to your computer and use it in GitHub Desktop.
Save anonymous/1917840 to your computer and use it in GitHub Desktop.
class Users::MygiftsController < ApplicationController
before_filter :authenticate_user!
def index
@gifts = Array.new
@giftea = Hash.new
@myself = FbGraph::User.me(session[:omniauth]["credentials"]["token"]).fetch()
@giftsuser = GiftsUsers.all(:conditions => {:receiver_id => @myself.identifier})
@giftsuser.each do |giftuser|
@gif = Gift.find(giftuser.gift_id)
@giftea['name'] = @gif.name
@giftea['original_price'] = @gif.original_price
@giftea['id'] = giftuser.id
@user = User.find(giftuser.user_id)
@giftea['sender'] = @user.first_name + ' ' + @user.last_name
if giftuser.status = 1
@giftea['status'] = "VALID"
elsif giftuser.status = 2
@giftea['status'] = "REDEEMED"
else
@giftea['status'] = "EXPIRED"
end
@gifts.push(@giftea)
end
respond_to do |format|
format.html # index.html.erb
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment