Categories aren't seeded Question
+1
−0
I followed the instructions here, but even after running rails db:seed
, there aren't any categories.
Console:
moshi@Alpha:~/qpixel$ rails db:create
Running via Spring preloader in process 11391
Created database 'qpixel_dev'
Created database 'qpixel_test'
moshi@Alpha:~/qpixel$ rails db:schema:load
moshi@Alpha:~/qpixel$ rails r db/scripts/create_tags_path_view.rb
Running via Spring preloader in process 11401
moshi@Alpha:~/qpixel$ rails db:migrate
Running via Spring preloader in process 11406
moshi@Alpha:~/qpixel$ rails c
Running via Spring preloader in process 11412
Loading development environment (Rails 7.0.4)
irb(main):001:0> Community.create(name: 'Dev Community', host: 'localhost:3000')
TRANSACTION (0.6ms) BEGIN
Community Exists? (0.9ms) SELECT 1 AS one FROM `communities` WHERE `communities`.`host` = 'localhost:3000' LIMIT 1
Community Create (0.5ms) INSERT INTO `communities` (`name`, `host`, `created_at`, `updated_at`, `is_fake`, `hidden`) VALUES ('Dev Community', 'localhost:3000', '2022-09-19 00:34:06', '2022-09-19 00:34:06', FALSE, FALSE)
TRANSACTION (16.7ms) COMMIT
=>
#<Community:0x0000564c6852e710
id: 1,
name: "Dev Community",
host: "localhost:3000",
created_at: Mon, 19 Sep 2022 00:34:06.000000000 UTC +00:00,
updated_at: Mon, 19 Sep 2022 00:34:06.000000000 UTC +00:00,
is_fake: false,
hidden: false>
irb(main):002:0> Rails.cache.clear
=> nil
moshi@Alpha:~/qpixel$ rails db:seed
Running via Spring preloader in process 11439
PostType: Created 5, skipped 0
CloseReason: Created 5, skipped 0
License: Created 5, skipped 0
TagSet: Created 3, skipped 0
PostHistoryType: Created 12, skipped 0
Ability: Created 7, skipped 0
Category: Created 0, skipped 2
PostFlagType: Created 4, skipped 0
Post: Created 15, skipped 5
ReactionType: Created 3, skipped 0
SiteSetting: Created 67, skipped 0
User: Created 1, skipped 0
WarningTemplate: Created 3, skipped 0
http://localhost:3000/categories:
Checking via console:
moshi@Alpha:~/qpixel$ rails c
Running via Spring preloader in process 11500
Loading development environment (Rails 7.0.4)
irb(main):001:0> Category.all.to_a
Category Load (0.6ms) SELECT `categories`.* FROM `categories` WHERE `categories`.`community_id` IS NULL
=> []
Clearly, the categories haven't been seeded. What did I do wrong, and how do I fix this?
1 answer
+1
−0
I do not really know why rails db:schema:load
stopped giving output, but it still does create all the tables as intended. The seeding of categories did indeed break due to rails being more strict on required elements for its relations. I have addressed this issue in https://github.com/codidact/qpixel/pull/897 .
0 comment threads