Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgronlund committed Dec 15, 2015
1 parent ca3cad7 commit 0543e42
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/controllers/shop/shipping_address_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def new
end
@address = Address.new
if current_user
@address.uuid = @shop_order.id
@address.address_type = @shop_order.class.name
@address.first_name = current_user.first_name
@address.last_name = current_user.last_name
@address.city = current_user.city
Expand Down Expand Up @@ -71,7 +73,8 @@ def address_params
:state,
:country,
:addressable_id,
:addressable_type)
:addressable_type,
:uuid)
end

end
2 changes: 1 addition & 1 deletion app/mailers/invoice_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def send_to_buyer
invoice = render_to_string('shop/invoices/notify_buyer_email', layout: 'invoices')

invoice_url = url_for( controller: 'shop/invoices', action: 'show', id: @shop_order.id )
ap invoice_url

begin
template_name = "invoice"
template_content = []
Expand Down
1 change: 1 addition & 0 deletions app/models/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def raise_accounts_version
end

def self.get_invoice_nr
#!!! thread safe no?
admin = Admin.first_or_create
admin.update(orders_count: admin.orders_count + 1)
admin.orders_count
Expand Down
2 changes: 1 addition & 1 deletion app/models/shop/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def require_shipping_address
end

def shipping_address
Address.find_by(addressable_id: self.id, addressable_type: self.class.name)
Address.find_by(uuid: self.id, addressable_type: self.class.name)
end

def payment_source
Expand Down
1 change: 1 addition & 0 deletions app/views/shop/shipping_address/_form.slim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
.col-sm-6
= f.input :country
= f.hidden_field :addressable_id , value: @shop_order.id
= f.hidden_field :uuid , value: @shop_order.id
= f.hidden_field :addressable_type , value: @shop_order.class.name


Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20151215212506_add_uuid_to_address.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddUuidToAddress < ActiveRecord::Migration
def change
add_column :addresses, :uuid, :uuid
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20151210131408) do
ActiveRecord::Schema.define(version: 20151215212506) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -235,6 +235,7 @@
t.datetime "updated_at", null: false
t.string "zip_code"
t.string "middle_name"
t.uuid "uuid"
end

add_index "addresses", ["addressable_type", "addressable_id"], name: "index_addresses_on_addressable_type_and_addressable_id", using: :btree
Expand Down

0 comments on commit 0543e42

Please sign in to comment.