タグ

ブックマーク / underrails.seesaa.net (1)

  • 自己参照 has_many: Rails開発日記

    create_table "users", options do |t| t.column "nickname", :string t.column "created_at", :datetime end create_table "friends", options do |t| t.column "my_id", :integer t.column "friend_id", :integer t.column "created_at", :datetime end class Friend < ActiveRecord::Base belongs_to :friend_shipped, :foreign_key=>:friend_id, :class_name => "User" belongs_to :befriend_shipped, :foreign_key=>:my_id, :

    uchiuchiyama
    uchiuchiyama 2010/12/29
    has_many :through でクラス名と別の名前を使いたいときは、:sourceで:belongs_toの名前を指定する
  • 1