Post History
#3: Post edited
- 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](https://collab.codidact.org/posts/285517), 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.
- 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](https://collab.codidact.org/posts/285517), 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](https://github.com/codidact/qpixel/issues/638) from August 21 that is related to seeding, but contains only little information at the moment.
#2: Post edited
- 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?
- 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](https://collab.codidact.org/posts/285517), 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.
#1: Initial revision
Error undefined method `has_tags' or `id' for nil:NilClass during rails db:seed
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?