Created
February 26, 2012 17:22
-
-
Save anonymous/1917840 to your computer and use it in GitHub Desktop.
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
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