Skip to content

Commit cc6a353

Browse files
committed
Seed database with default sounds
1 parent 627e291 commit cc6a353

11 files changed

Lines changed: 19 additions & 0 deletions

File tree

api/db/seeds.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,22 @@
77
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
88
# MovieGenre.find_or_create_by!(name: genre_name)
99
# end
10+
11+
default_sounds = [
12+
{ name: 'Airhorn', file_path: 'airhorn.mp3' },
13+
{ name: 'Anime Wow', file_path: 'anime-wow.mp3' },
14+
{ name: 'Applause', file_path: 'applause.mp3' },
15+
{ name: 'Background Music', file_path: 'bg-music.mp3' },
16+
{ name: 'Crickets', file_path: 'crickets.mp3' },
17+
{ name: 'Drumroll', file_path: 'drumroll.mp3' },
18+
{ name: 'Explosion', file_path: 'explosion.mp3' },
19+
{ name: 'Quack', file_path: 'quack.mp3' },
20+
{ name: 'Splat', file_path: 'splat.mp3' },
21+
{ name: 'Yippee', file_path: 'yippee.mp3' }
22+
]
23+
24+
default_sounds.each do |sound|
25+
Sound.find_or_create_by!(name: sound[:name]) do |s|
26+
s.audio_file.attach(io: File.open(Rails.root.join("db", "seeds", "audio", sound[:file_path])), filename: sound[:file_path])
27+
end
28+
end

api/db/seeds/audio/airhorn.mp3

25.6 KB
Binary file not shown.

api/db/seeds/audio/anime-wow.mp3

66.1 KB
Binary file not shown.

api/db/seeds/audio/applause.mp3

344 KB
Binary file not shown.

api/db/seeds/audio/bg-music.mp3

2.61 MB
Binary file not shown.

api/db/seeds/audio/crickets.mp3

79.1 KB
Binary file not shown.

api/db/seeds/audio/drumroll.mp3

63.6 KB
Binary file not shown.

api/db/seeds/audio/explosion.mp3

33.4 KB
Binary file not shown.

api/db/seeds/audio/quack.mp3

3.54 KB
Binary file not shown.

api/db/seeds/audio/splat.mp3

12.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)