Skip to content

Commit

Permalink
Added ethnicity model and seeds (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnyon-grandkru authored Feb 26, 2024
1 parent 50d72a8 commit 875e237
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/ethnicity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Ethnicity < ApplicationRecord
end
9 changes: 9 additions & 0 deletions db/migrate/20240226111206_create_ethnicities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateEthnicities < ActiveRecord::Migration[7.1]
def change
create_table :ethnicities do |t|
t.string :title
t.string :slug
t.timestamps
end
end
end
9 changes: 8 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,20 @@
State.create(state)
end
end

if Ethnicity.count.zero?
puts 'Creating Ethnicities...'
ethnicities = [
['Black'],
['White'],
['Hispanic'],
['Native American'],
['Asian'],
['Arabic'],
['Pacific Islander']
]

ethnicities.each do |ethnicity|
Ethnicity.create(title: ethnicity[0])
end
end
5 changes: 5 additions & 0 deletions spec/factories/ethnicities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryBot.define do
factory :ethnicity do

end
end

0 comments on commit 875e237

Please sign in to comment.