버전 8에 PaperTrail을 사용하려고 시도합니다. 내 연관이 되돌아 가지 않습니다. 나는 틀린 일을해야만합니다. 여기 내 비슷한 설정이 있습니다. PaperTrail의 최신 마스터 브랜치를 사용하고 있습니다.has_many와 함께 PaperTrail 버전 관리를 사용하는 방법 : 레일을 통한 연관성 확인 4
class Ball < ActiveRecord::Base
has_many :ball_colors
has_many :colors, through: :ball_colors
has_paper_trail
end
class BallColor < ActiveRecord::Base
belongs_to :ball
belongs_to :color
has_paper_trail
end
class Color < ActiveRecord::Base
has_paper_trail
has_many :ball_colors
has_many :balls, through: :ball_colors
end
이것이 내가하는 일입니다.
ball = Ball.create()
ball.name = 'Before I add color'
ball.save
ball.colors << Color.create(name: 'blue')
ball.save #although this is unnecessary i think
ball.name = 'After adding color'
ball.save
b = ball.versions.last.reify(:has_many => true)
b.save
b.reload
b.name #=> 'Before I add color'
b.colors #=> [Blue]
b.colors는 비워 두어야합니다. 또한 볼에 색을 추가 할 때 ball.versions에 변경 사항이 포함되지 않습니다. '색상을 추가하기 전에'에 대한 업데이트, '색상 추가 후'에 대한 업데이트 만 생성됩니다. 누군가 내가 잘못하고있는 것을 말해 주거나 예를 들어 설명해 줄 수 있습니까? 설명서의 연관성 섹션을 읽었으나 아무 소용이 없습니다.
'validates : models, length : {minimum : 1}'이 (가) has_many를 re_many하는 방법을 알고 있다면 다른 사람의 말에 대해서는 언급 할 수 없습니다. 레코드는 유효성 검사없이 연결과 올바르게 복원되지만 유효성 검사에서는 유효성 검사 실패에 대한 불평을 저장하지 않습니다. – Kei