Skip to content

Commit

Permalink
Added seeds for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mjacobus committed Jun 12, 2014
1 parent a915d51 commit d7e0853
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@
t.string "uid"
t.text "provider_data"
t.string "name"
t.integer "city_id"
end

add_index "users", ["city_id"], name: "index_users_on_city_id", using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["provider", "uid"], name: "index_users_on_provider_and_uid", unique: true, using: :btree

Expand Down
28 changes: 28 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
require_relative 'seeds/brazilian_states_and_cities'
require_relative "seeds/development" if Rails.env.development?

Tag.find_or_create_by!({
name: 'Home Office'
})

Tag.find_or_create_by!({
name: 'Full Time'
})

Tag.find_or_create_by!({
name: 'Part Time'
})

Tag.find_or_create_by!({
name: 'Presencial'
})

Tag.find_or_create_by!({
name: 'PJ'
})

Tag.find_or_create_by!({
name: 'CLT'
})

Tag.find_or_create_by!({
name: 'Freela'
})
8 changes: 7 additions & 1 deletion db/seeds/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ def random
ActiveRecord::Base.send(:include, RandomRecords)

30.times do
Job.make!(city: City.random)
job = Job.make!(city: City.random)

begin
job.tags << Tag.random
job.tags << Tag.random
rescue ActiveRecord::RecordNotUnique => e
end
end

0 comments on commit d7e0853

Please sign in to comment.