Ok, try running this in the rails console. What number does it give?
Category.find_by(name: 'Your Category Name').topics.count
You can list the topic titles like this:
Category.find_by(name: 'Your Category Name').topics.pluck(:title)
Ok, try running this in the rails console. What number does it give?
Category.find_by(name: 'Your Category Name').topics.count
You can list the topic titles like this:
Category.find_by(name: 'Your Category Name').topics.pluck(:title)
Okay, that’s what I got:
[1] pry(main)> Category.find_by(name: ‘Discord’).topics.count
=> 1
[2] pry(main)> Category.find_by(name: ‘Discord’).topics.pluck(:title)
=> [“O kategorii Discord”]
Please can you try these as well:
Category.find_by(name: 'Discord').topic_count
Category.find_by(name: 'Discord').topics.pluck(:id)
Category.find_by(name: 'Discord').topic_id
Here you are:
[5] pry(main)> Category.find_by(name: ‘Discord’).topics.pluck(:id)
=> [17]
[4] pry(main)> Category.find_by(name: ‘Discord’).topic_id
=> 17
Those two look ok, what about the first one in my list?
I already sent you output of this command in last reply, but anyway:
[10] pry(main)> Category.find_by(name: ‘Discord’).topic_count
=> 1
topics.count
is different to topic_count
I think something is going wrong with your topic_count
. By all the commands you’ve run, I think it should be zero (it is supposed to ignore the category description topic).
So, to reset it, run
Category.find_by(name: 'Discord').update(topic_count: 0)
Then try deleting the category from the UI again.
It worked, thank you so much