Sha256: cf731ceb8aee7e988cba076f2b723f04aa140035ac24fa93f3ac568cd01c6bcc

Contents?: true

Size: 302 Bytes

Versions: 21

Compression:

Stored size: 302 Bytes

Contents

class AddSlugToStories < ActiveRecord::Migration
  def self.up
    add_column :stories, :slug, :string, :null => false, :default => ''
    Story.all.each do |story|
      story.slug = story.title.parameterize
      story.save!
    end
  end

  def self.down
    remove_column :stories, :slug
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
branston-0.3.2 lib/branston/db/migrate/20091204173634_add_slug_to_stories.rb