Create rake task to generate slug for objects that use Sluggable concern

Why:

* Once slug presence validation and usage is merged on to a code base, existing objects without it will become invalid and unusable

How:

* Running `bundle exec slugs:gnerate` will look for all models that include the concern, and generate a slug for each object
This commit is contained in:
Bertocq
2017-07-04 14:37:56 +02:00
parent e3d89261a6
commit 4068e50b33

8
lib/tasks/slugs.rake Normal file
View File

@@ -0,0 +1,8 @@
namespace :slugs do
desc "Generate slug attribute for objects from classes that use Sluggable concern"
task generate: :environment do
%w(Budget Budget::Heading Budget::Group).each do |class_name|
class_name.constantize.all.each(&:generate_slug)
end
end
end