Skip to content

Instantly share code, notes, and snippets.

@hchood
Created September 23, 2014 19:51
Show Gist options
  • Select an option

  • Save hchood/ab7fbe945854ae23d671 to your computer and use it in GitHub Desktop.

Select an option

Save hchood/ab7fbe945854ae23d671 to your computer and use it in GitHub Desktop.
Bus seeder
timeframes = [
"6-9 AM",
"9-12 PM",
"12-3 PM"
]
direction = [
"inbound",
"outbound"
]
day = [
"weekday",
"weekend"
]
# create all your buses using CSV.foreach
Bus.all.each do |bus|
timeframes.each do |timeframe|
direction.each do |direction|
day.each do |day|
ride_attrs = {
bus: bus,
timeframe: timeframe,
day: day
}
Ride.find_or_create_by(ride_attrs)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment