Take the 2008 Git User's Survey and help out! [ hide ]

public
Description: Your favorite URL-shortening service in all of Ruby land
Homepage: http://rubyurl.com
Clone URL: git://github.com/robbyrussell/rubyurl.git
Search Repo:
robbyrussell (author)
Wed May 14 08:44:53 -0700 2008
commit  65af4e584b40dd9663fa3eebf1b7e79df01335a7
tree    67ea5ee96b815a0c934477cb858162fb7291859c
parent  9c710b6160958e137b1ad24dc3f6b185d5c043ee
rubyurl / script / migrate-to-new
100644 24 lines (18 sloc) 0.477 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/ruby
require File.dirname(__FILE__) + '/../config/environment'
 
class Rubyurl < ActiveRecord::Base
end
 
@old_links = Rubyurl.find(:all)
 
@count = 0
 
@old_links.each do |old_link|
  # create new link
  
  @link = Link.find_or_create_by_website_url( old_link.website_url )
  @link.ip_address = '0.0.0.0'
  
  if @link.save
    @count += 1
    puts "saved ##{@count}"
  else
    puts @link.errors.to_yaml
    puts "unable to save #{@link.website_url}"
  end
end