Sha256: f0d201baed0201254a563c9d06c0c841fa9eaa6badc1a6437b76149b785d0998
Contents?: true
Size: 387 Bytes
Versions: 12
Compression:
Stored size: 387 Bytes
Contents
class AddSlugsToExistingPosts < ActiveRecord::Migration def up Blogelator::Post.all.each do |post| post.slug = post.title.parameterize existing_slug_count = post.class.where(slug: post.slug).count if existing_slug_count > 0 post.slug = post.slug + "-#{existing_slug_count}" end post.save end end def down # Do nothing end end
Version data entries
12 entries across 12 versions & 1 rubygems