Created
September 6, 2011 13:01
-
-
Save spk/1197471 to your computer and use it in GitHub Desktop.
Regenerate all the friendly_id slugs for models using friendly_id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
namespace :slugs do | |
desc "Regenerate all the friendly_id slugs for models using friendly_id" | |
task :regenerate => [:environment] do | |
models = ActiveRecord::Base.connection.tables.map(&:classify) - ["SchemaMigration", "Version"] | |
models.select {|m| m.constantize.uses_friendly_id? }.each do |model| | |
puts "* (Re)generating slugs for model #{model}" if verbose | |
sh "rake friendly_id:redo_slugs MODEL=#{model}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment