Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created October 24, 2011 22:30
Show Gist options
  • Save brandon-beacher/1310568 to your computer and use it in GitHub Desktop.
Save brandon-beacher/1310568 to your computer and use it in GitHub Desktop.
ActiveRecord::Base.connection.execute("CREATE OR REPLACE VIEW emails AS select gift_cards.id AS emailable_id, 'GiftCard' AS emailable_type, gift_cards.created_at AS created_at, gift_cards.updated_at AS updated_at, gift_cards.cart_id AS cart_id, gift_cards.amount AS amount, gift_cards.deliver_on AS deliver_on, gift_cards.delivered_at AS delivered_at, gift_cards.deliver_via_email AS deliver_via_email, gift_cards.recipient_email AS recipient_email from gift_cards where (gift_cards.deliver_via_email = true) union select notes.id AS emailable_id, 'Note' AS emailable_type, notes.created_at AS created_at, notes.updated_at AS updated_at, notes.cart_id AS cart_id, notes.amount AS amount, notes.deliver_on AS deliver_on, notes.delivered_at AS delivered_at, notes.deliver_via_email AS deliver_via_email, notes.recipient_email AS recipient_email from notes where (notes.deliver_via_email = true);")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment