Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
"Re-send a gift coupon" feature I implemented on a Ruby on Rails application at my last job
# only including what I helped write below
.coupon_list
- array_of_coupons.each do |coupon|
%div
- if redeemed
%span.cross_out
= "#" + coupon.uid
%span.green
= link_to (coupon.user_redeemed ? "Mark as New" : "Mark as Used"), '#', :class => 'user_redeemed', :rel => toggle_user_redeemed_coupon_path(coupon)
-elsif !redeemed && !coupon.gift
%span
= "#" + coupon.uid
%span.redeemed
= link_to 'Print', "/offers/#{offer_option.offer_id}/coupons/#{coupon.id}.pdf"
|
= link_to (coupon.user_redeemed ? "Mark as New" : "Mark as Used"), '#', :class => 'user_redeemed', :rel => toggle_user_redeemed_coupon_path(coupon)
-else
%span
= "#" + coupon.uid
%span.redeemed
= link_to 'Print', "/offers/#{offer_option.offer_id}/coupons/#{coupon.id}.pdf"
|
= link_to 'Resend', edit_coupon_gift_path(coupon.id, coupon.gift.id), :rel => "facebox"
#content
%h1
NEW DEALS
%hr
= render 'coupon_block', :offer_options_hash => @unredeemed_hash, :redeemed => false
%h1
REDEEMED
%hr
= render 'coupon_block', :offer_options_hash => @redeemed_hash, :redeemed => true
- unless @gifts_hash.empty?
%h1#gifts
GIFTS
%hr
= render 'coupon_block', :offer_options_hash => @gifts_hash, :redeemed => false
= link_to "Back", :back
- if flash[:offer_id]
#share_reminder_window.hidden
= render :partial => 'shares/share_reminder', :locals => { :offer => @offer, :user => current_user, :image_name => (@offer && @offer.image ? @offer.image.image_file_name : "blank.png" ) }
#can't include everything, below is what I helped write
def consumer_index
include_facebox
@custom_csses << "compiled/gifts/edit.css"
if current_user
unredeemed_array = []
redeemed_array = []
gifts_array = []
current_user.coupons.each do |c|
unredeemed_array << c unless c.user_redeemed || c.gift
redeemed_array << c if c.user_redeemed
gifts_array << c if c.gift
end
@unredeemed_hash = unredeemed_array.sort_by{|c| c.offer_option.offer.title }.group_by { |x| x.offer_option }
@redeemed_hash = redeemed_array.sort_by{|c| c.offer_option.offer.title }.group_by { |x| x.offer_option}
@gifts_hash = gifts_array.sort_by{|c| c.offer_option.offer.title }.group_by { |x| x.offer_option}
@offer = Offer.find(flash[:offer_id]) if flash[:offer_id]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.