toolmantim / webjam

Old repository for webjam. New one lives at http://github.com/webjam/webjam

This URL has Read+Write access

toolmantim (author)
Tue Sep 09 06:41:24 -0700 2008
commit  cd4c4a9d1539a6e6e18484caf4cea10bb05dcc40
tree    b3cb761497936f81dc28a3c913fc3c5028915f4b
parent  4f4e3e51d4c29817f268eecb1cc54d454bf8e09a
webjam / script / import_old_blog_posts
100755 23 lines (17 sloc) 0.708 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env ruby
 
require File.dirname(__FILE__) + '/../config/environment'
 
require 'rubygems'
require 'activerecord'
require 'yaml'
 
class Post < ActiveRecord::Base; end
class User < ActiveRecord::Base; end
 
lacho = User.find_by_nick_name("lachlanhardy")
raise "Lachlan doesnt exist! Odd eh." unless lacho
 
YAML.load(File.open(File.dirname(__FILE__) + "/blog_posts.yml").read).each do |post|
  Post.create :user_id => lacho.id,
              :title => post[:title],
              :body => post[:body],
              :permalink => post[:permalink],
              :published_at => (Time.parse(post[:published_at]) - 10.hours),
              :year => (Time.parse(post[:published_at]) - 10.hours).year
end