This commit is contained in:
Sunandar
2017-02-08 17:35:37 +06:30
parent 0b4e69d1be
commit 26d42631c7
14 changed files with 140 additions and 95 deletions

View File

@@ -10,5 +10,32 @@ namespace :setup do
lookup.max_length=16
lookup.save
end
end
desc "Product Type"
task :set_product_type, [:name] => :environment do |t, args|
find_product_type=ProductType.find_by_name(args.name)
if find_product_type.nil?
product_type=ProductType.new
product_type.name=args.name
product_type.save
else
puts 'Product Type is already taken!'
end
end
desc "Product Categories"
task :set_product_category, [:name,:product_type] => :environment do |t, args|
find_product_type=ProductType.find_by_id(args.product_type)
if !find_product_type.nil?
find_product_category=ProductCategory.find_by_name(args.name)
if find_product_category.nil?
product_category=ProductCategory.new
product_category.name=args.name
product_category.product_type_id=args.product_type
product_category.save
end
else
puts 'Produt Type does not exist!'
end
end
end