I want the topic_order field starting from 1, currently it sorted from first to last but start anywhere, I want a migration to bulk update all the topics so it starts from 1 until n.
I could make:
def change
i=1
Topic.all.each do |topic|
topic.update(topic_order: i)
i += 1
end
end
But is not efficient, I got hundreds of topics, Is there any way to make it better and faster? Thanks in advance