edit api
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user