Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
Q&A Categories aren't seeded

1 answer  ·  posted 2y ago by Moshi‭  ·  last activity 2y ago by Moshi‭

Question support setup
#1: Initial revision by user avatar Moshi‭ · 2022-09-19T00:47:28Z (about 2 years ago)
Categories aren't seeded
I followed the instructions [here](https://collab.codidact.org/posts/280451), 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:

![Image alt text](https://collab.codidact.org/uploads/E5aSnsrYRecWcoLgEUonE8V3)

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?