내 코드STI와 형체는
class Post < ActiveRecord::Base
end
class NewsArticle < Post
has_many :comments, :as => :commentable, :dependent => :destroy, :order => 'created_at'
end
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true, :counter_cache => true
end
로 그리고 내가
Comment Load (0.9ms) SELECT "comments".* FROM "comments" WHERE ("comments"."commentable_id" = 1 and "comments"."commentable_type" = 'Post') ORDER BY created_at
이상한처럼 로그 무언가 참조 일부 NewsArticle에 대한 의견을 가서 시도에서 문제가 "commentable_type"= '포스트 그 '. 무엇이 잘못 되었나요?
PS는 : 2.3.5 & & 루비 1.8.7은 (2010-01-10 패치 레벨이 249)는 i686가-darwin10 상기 commentable_type 필드는 테이블의 이름을 저장해야
huh ... 테이블 이름은 정확하지만 STI 모델 이름이 잘못되었습니다. –
다형성 관계의 경우 테이블 만로드되면 해당 테이블이 상속 유형을 결정할 수 있습니다. – danivovich