I have the following rake task:
update_rank.rake
task :build => :environment do
Result.desc(:score).each_with_index do |result, position|
result.update_attribute(:rank, position + 1)
end
end
I want to call this task from the controller whenever a result is created. What is the best way to do this? Should i instead move this task into a model?