Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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
Add Comment
Please, Sign In to add comment