![](http://bp3.blogger.com/_RGGAxF8f5a8/Rg-0-OSKY5I/AAAAAAAAADE/MG2a6IKZYKs/s320/Screenshot_2.png)
てな感じにモデリングしてymlを吐き出す。それからrailsのmodel generatorを呼び出して、関係情報をmodelに突っ込むrubyスクリプトも。
class CreateSubscriptions < ActiveRecord::Migration
def self.up
create_table :subscriptions do |t|
t.column :user_id, :integer
t.column :newsletter_id, :integer
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.column :name, :text
t.column :age, :integer
class CreateNewsletters < ActiveRecord::Migration
def self.up
create_table :newsletters do |t|
t.column :date, :datetime
t.column :content, :text
t.column :title, :text
class Newsletter < ActiveRecord::Base
has_many :subscriptions
has_many :users, :through => :subscriptions
end
class Subscription < ActiveRecord::Base
belongs_to :user
belongs_to :newsletter
end
class User < ActiveRecord::Base
has_many :subscriptions
has_many :newsletters, :through => :subscriptions
end
配布はのちほど。