I have a simple polymorphic association
#comment.rb
belongs_to :commentable, :polymorphic => true
has_many :comments, :as => :commentable
#post.rb
has_many :comments, :as => :commentable
accepts_nested_attributes_for :comments, :allow_destroy => true
So in IRB I can do, Post.comments, or Comment.comments.
But how can I find the parent post?
As in Comment.post ?
I can currently get their by doing a series of .commentable
's. For example :
Comment.find(1).commentable.commentable
=> Post(:id => ...