Add some posts to seeds.rb

This commit is contained in:
riggraz
2019-08-25 11:26:28 +02:00
parent 87c205ca60
commit 735b0de9b6

View File

@@ -1,16 +1,40 @@
# Create an admin user and confirm its email automatically
admin = User.create(email: "admin@example.com", password: "password", role: "admin", full_name: "Admin")
admin = User.create(email: 'admin@example.com', password: 'password', role: 'admin', full_name: 'Admin')
admin.confirm
# Create a board
board = Board.create(name: "Feature Requests")
# Create some boards
feature_board = Board.create(name: 'Feature Requests', description: 'Post here your feature requests.')
bug_board = Board.create(name: 'Bug Reports', description: 'Post here your bug reports.')
# Create some post statuses
planned_post_status = PostStatus.create(name: "Planned", color: "#0096ff")
in_progress_post_status = PostStatus.create(name: "In Progress", color: "#9437ff")
completed_post_status = PostStatus.create(name: "Completed", color: "#6ac47c")
rejected_post_status = PostStatus.create(name: "Rejected", color: "#ff2600")
planned_post_status = PostStatus.create(name: 'Planned', color: '#0096ff')
in_progress_post_status = PostStatus.create(name: 'In Progress', color: '#9437ff')
completed_post_status = PostStatus.create(name: 'Completed', color: '#6ac47c')
rejected_post_status = PostStatus.create(name: 'Rejected', color: '#ff2600')
puts "A default admin user has been created. Credentials:"
# Create some posts
Post.create(
title: 'This is how users give you feedback',
description: 'They can also provide an extendend description like this... bla bla...',
board_id: feature_board.id,
user_id: admin.id
)
Post.create(
title: 'You can assign a status to each post',
description: 'This one, for example, is marked as "Planned"',
board_id: feature_board.id,
user_id: admin.id,
post_status_id: planned_post_status.id
)
Post.create(
title: 'There are multiple boards',
description: 'For now you have Feature Requests and Bug Reports, but you can add or remove as many as you want!',
board_id: bug_board.id,
user_id: admin.id,
post_status_id: in_progress_post_status.id
)
# Let the user know how to log in with admin account
puts 'A default admin account has been created. Credentials:'
puts "-> email: #{admin.email}"
puts "-> password: #{admin.password}"