Sha256: abe3dc79b5372542ba2e3deae41f5f0a5d520feaedb22403c21eccbe636b60ff
Contents?: true
Size: 454 Bytes
Versions: 12
Compression:
Stored size: 454 Bytes
Contents
# This migration comes from blogelator (originally 20140224175024) 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