コードに問題がある
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
そして、いくつかの NewsArticle のコメントを取得しようとすると、ログに次のようなものが表示されます
Comment Load (0.9ms) SELECT "comments".* FROM "comments" WHERE ("comments"."commentable_id" = 1 and "comments"."commentable_type" = 'Post') ORDER BY created_at
"commentable_type" = 'Post'というのは奇妙です。どうしたの?
PS: Rails 2.3.5 && ruby 1.8.7 (2010-01-10 パッチレベル 249) [i686-darwin10]