Skip to content

Instantly share code, notes, and snippets.

@sbauch
Created May 6, 2013 23:39
Show Gist options
  • Save sbauch/5529179 to your computer and use it in GitHub Desktop.
Save sbauch/5529179 to your computer and use it in GitHub Desktop.
this might help?
get '/' do
# Create Account
company_name = "Company_" + rand(1000000).to_s
new_account = Account.create(name: company_name)
# not sure whats going on here?
# new_account.name = "1 "+ company_name
# new_account.save!
# Create User
user_name = "Frank_"+ rand(1000000).to_s
# user.password = "pass"
new_account.users.create(user_name: user_name, password: "pass")
# user.save
#
# new_account.users = [user]
# new_account.save
# not changing this since the embedded nature its best to just save the document once
# Create Standard Item
new_standard = Standard.new(name: "American Apparel "+rand(10000).to_s)
new_price = Price.new(base_cost: 1000, quantity: 25, colors:1)
new_price2 = Price.new(base_cost: 1000, quantity: 50, colors:1)
new_standard.prices << new_price
new_standard.prices << new_price2
new_standard.save
# Create Item -> Use StandardItem
new_item = new_standard.items.create(description: "This shirt rocks ",name: "Threads Shirt ")
#you had:
# new_item = Item.new(description: "This shirt rocks ",name: "Threads Shirt ")
# new_item.standard = new_standard
# #new_item.save
# Create File
new_item.myfiles.create(url: "http://teespring.com/uploads/2013/04/28/23/46102/shirtFront.jpg?v=2013-04-28%2023%3A16%3A28",
name:"file"+rand(1000).to_s,
location:"Front")
#you had:
# new_file = Myfile.new(url: "http://teespring.com/uploads/2013/04/28/23/46102/shirtFront.jpg?v=2013-04-28%2023%3A16%3A28" , name:"file"+rand(1000).to_s, location:"Front")
# new_file.save
# new_item.myfiles = [new_file]
# new_item.save
# Add Item to Account
new_account.items << new_item
new_account.save
# Create Order - Restock
# Check for quantity
# Create Inventory
#new_inventory = Inventory.new()
# Create Order - Inventory
puts "After output account: "
@accounts = Account.all
erb :index
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment