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

Error undefined method `has_tags' or `id' for nil:NilClass during rails db:seed Question

+1
−0

When running rails db:seed I get some errors without any further explanation.

CloseReason: Created 0, skipped 5
User: Created 0, skipped 1
PostFlagType: Created 0, skipped 4
PostType: Created 0, skipped 5
ReactionType: Created 0, skipped 3
SiteSetting: Created 0, skipped 57
Got error undefined method `has_tags' for nil:NilClass. Continuing...
Ability: Created 0, skipped 7
PostHistoryType: Created 0, skipped 12
Got error undefined method `id' for nil:NilClass. Continuing...
WarningTemplate: Created 0, skipped 3
TagSet: Created 0, skipped 2
License: Created 0, skipped 5

Are they critical? Should I do something?


I tried to setup QPixel again and while I could avoid another error, this one persists. I gathered more information by adding to the rescue clause of db/seeds.rb

puts "#{e.class}: #{e.message}"
puts e.backtrace.join("\n")

and got

Post
Got error undefined method `has_tags' for nil:NilClass. Continuing...
NoMethodError: undefined method `has_tags' for nil:NilClass
/home/abanta/qpixel/app/models/post.rb:52:in `block in <class:Post>'
...
/home/abanta/qpixel/db/seeds.rb:56:in `block (2 levels) in <top (required)>'
/home/abanta/qpixel/db/seeds.rb:21:in `each'
/home/abanta/qpixel/db/seeds.rb:21:in `block in <top (required)>'
/home/abanta/qpixel/db/seeds.rb:11:in `each'
/home/abanta/qpixel/db/seeds.rb:11:in `<top (required)>'

Category
Got error undefined method `id' for nil:NilClass. Continuing...
NoMethodError: undefined method `id' for nil:NilClass
(erb):4:in `block in <top (required)>'
/usr/lib/ruby/2.7.0/erb.rb:905:in `eval'
/usr/lib/ruby/2.7.0/erb.rb:905:in `result'
/home/abanta/qpixel/db/seeds.rb:16:in `block in <top (required)>'
/home/abanta/qpixel/db/seeds.rb:11:in `each'
/home/abanta/qpixel/db/seeds.rb:11:in `<top (required)>'

In the database SELECT * FROM post_types delivers

+----+-----------+-------------+-------------+-----------+----------+------------+--------------+-------------+--------------------+--------------+--------------+--------------------+-----------+----------------+---------------+-----------------------------+
| id | name      | description | has_answers | has_votes | has_tags | has_parent | has_category | has_license | is_public_editable | is_closeable | is_top_level | is_freely_editable | icon_name | answer_type_id | has_reactions | has_only_specific_reactions |
+----+-----------+-------------+-------------+-----------+----------+------------+--------------+-------------+--------------------+--------------+--------------+--------------------+-----------+----------------+---------------+-----------------------------+
|  1 | Answer    | NULL        |           0 |         1 |        0 |          1 |            1 |           1 |                  1 |            0 |            0 |                  0 | NULL      |           NULL |             1 |                           0 |
|  2 | PolicyDoc | NULL        |           0 |         0 |        0 |          0 |            0 |           0 |                  0 |            0 |            0 |                  0 | NULL      |           NULL |             0 |                           0 |
|  3 | HelpDoc   | NULL        |           0 |         0 |        0 |          0 |            0 |           0 |                  0 |            0 |            0 |                  0 | NULL      |           NULL |             0 |                           0 |
|  4 | Article   | NULL        |           0 |         1 |        1 |          0 |            1 |           1 |                  1 |            0 |            1 |                  0 | NULL      |           NULL |             0 |                           0 |
+----+-----------+-------------+-------------+-----------+----------+------------+--------------+-------------+--------------------+--------------+--------------+--------------------+-----------+----------------+---------------+-----------------------------+

Maybe that helps finding the cause and judging the severity of the issue.

I found a issue on Github from August 21 that is related to seeding, but contains only little information at the moment.

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

I'm having this issue too (1 comment)
Honestly, it sounds like there's something wrong with your setup somewhere - maybe a missed step, may... (7 comments)

0 answers

Sign up to answer this question »