Rails 多対多
PostとCategoryの多対多の関係を作成する
modelの作成
rails generate scaffold Post title:string content:text
rails generate scaffold Category value:string
modelの制作
rails generate model モデル名 カラム名:データ型 カラム名:データ型
rails generate model category_post post_id:integer category_id:integer
class CategoryPost < ActiveRecord::Base attr_accessible :category_id, :post_id belongs_to :category belongs_to :post end
typeは予約後でスキーマには使えない。
ref
多対多
http://blog.s21g.com/articles/805
http://namakesugi.blog42.fc2.com/blog-entry-100.html
Active Admin
http://b.hatena.ne.jp/sessan/activeadmin/
Active admin
http://stackoverflow.com/questions/13130809/custom-active-admin-form-inputs-for-has-and-belongs-to-many-relationship