1
을 통해 몇 가지 좀이 연결을 할 수 있나요 :has_many : 협회
사용자 모델 :이 기록되고
u = User.first
u.goods_want << Good.first
u.save
콘솔
has_many :goods, :through => :assignments
has_many :goods_want, :through => :assignments, :source => :good, :conditions => "assignments.type = 1"
테스트 :
INSERT INTO `assignments` (`good_id`, `updated_at`, `type`, `profile_id`, `created_at`) VALUES(1, '2009-03-26 09:36:11', NULL, 1, '2009-03-26 09:36:11')
그래서이 연관성을 데이터베이스에서 레코드를 가져 오는 것뿐만 아니라 데이터베이스에 쓸 수있는 아름다운 방법이 있습니까?
출력 형식을 어떻게 지정 하시겠습니까? – vrish88