VariantOverrides require hub and variant

This commit is contained in:
Rohan Mitchell
2014-12-11 10:39:26 +11:00
parent 0393007ba5
commit 45e709b2cc
3 changed files with 12 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
class VariantOverride < ActiveRecord::Base
belongs_to :variant, class_name: 'Spree::Variant'
belongs_to :hub, class_name: 'Enterprise'
belongs_to :variant, class_name: 'Spree::Variant'
validates_presence_of :hub_id, :variant_id
scope :for_hubs, lambda { |hubs|
where(hub_id: hubs)

View File

@@ -0,0 +1,6 @@
class AddNotNullToVariantOverrideRelations < ActiveRecord::Migration
def change
change_column :variant_overrides, :hub_id, :integer, null: false
change_column :variant_overrides, :variant_id, :integer, null: false
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20141113053004) do
ActiveRecord::Schema.define(:version => 20141210233407) do
create_table "adjustment_metadata", :force => true do |t|
t.integer "adjustment_id"
@@ -1034,8 +1034,8 @@ ActiveRecord::Schema.define(:version => 20141113053004) do
end
create_table "variant_overrides", :force => true do |t|
t.integer "variant_id"
t.integer "hub_id"
t.integer "variant_id", :null => false
t.integer "hub_id", :null => false
t.decimal "price", :precision => 8, :scale => 2
t.integer "count_on_hand"
end