Created
August 30, 2012 18:35
-
-
Save binaryphile/3536938 to your computer and use it in GitHub Desktop.
deface override
This file contains 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
Deface::Override.new(virtual_path: 'spree/checkout/_payment', | |
name: 'add_referral_select_to_checkout_payment_step', | |
insert_before: 'fieldset#payment', | |
text: '<fieldset id="billing"><legend><%= t(:referral) %></legend><div><p>If you were referred to us by one of our salespeople, please select their name:</p><%= form.collection_select :dibs_referral, Spree::User.all, :id, :email %></div></fieldset>' | |
) | |
module Spree | |
Order.class_eval do | |
belongs_to :dibs_referral, class_name: '::Spree::User' | |
attr_accessible :dibs_referral | |
accepts_nested_attributes_for :dibs_referral | |
end | |
end | |
class Initialize < ActiveRecord::Migration | |
def up | |
Spree::Role.find_or_create_by_name(:dibs_referral) | |
add_column :spree_orders, :dibs_referral_id, :integer | |
add_index :spree_orders, :dibs_referral_id, name: 'dibs_referral_id_ix' | |
end | |
def down | |
Spree::Role.where(name: :dibs_referral).each { |role| role.destroy } | |
remove_index :spree_orders, name: 'dibs_referral_id_ix' | |
remove_column :spree_orders, :dibs_referral_id | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment