Sha256: 047c247ab1e88074b32deaf8672f0deb6bfb8d7bca135bf16def1a34589b4307

Contents?: true

Size: 1.87 KB

Versions: 4

Compression:

Stored size: 1.87 KB

Contents

require_relative './easy_seeds/easy_seeds.rb'
require "open-uri"

=begin

Example of what your seeds.rb file should look like. Full project at https://github.com/mfong4151/Suber-Eats

___ CSV Seed_Files Setup ____

See the samples for how CSV's are set up. The headers need to match the database column names exactly. 
Use the format -- column_name:data_type -- for the headers. Easy_Seeder will do type conversion for you. Default is "string" and does not need to be declared. 
Accepted data types: string, integer, float, boolean, date. 
If you need an additional data type ping Marcos or Max and we can update. 

___ CSV Seed_Files Setup ____

Seed image files Require a Id, URL and Filename. You can copy these last two straight from the AWS console.
the Id will attach the image path to that Id's object instance. See "Easy Seeder Setup" for information on file ordering. 

___ Easy Seeder Setup ___

File order matters!
Place your model names in class_names for each class you are making Seed Data for. Each class needs its own CSV. 

The order of class_names and the order of files in seed_files should match your migration order (to prevent null database constraint failures).
EasySeeds.attach_images runs after all database instances are created. It uses the value in class_image_names 
to attach images to an instance of that Class_Name and Id. 

hit us up with questions. 

=end



class_names = [User, Restaurant, Menu, MenuItem, Review, Cart, CartItem, Transaction, Location]
table_strings = ['users', 'restaurants', 'menus', 'menu_items', 'reviews', 'carts', 'cart_items', 'transactions', 'locations']

EasySeeds::Destroy.destroy_tables(class_names, table_strings)

puts 'Creating easy seeds data'
class_names.delete_at(-1)
EasySeeds::Seeder.create_easy_seed_data(class_names)

class_image_names = [Restaurant]
EasySeeds::Images.attach_images(class_image_names)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
easy_seeds-1.0.4 demo/db/seeds.rb
easy_seeds-1.0.3 demo/db/seeds.rb
easy_seeds-1.0.2 demo/db/seeds.rb
easy_seeds-1.0.0 demo/db/seeds.rb