i can''t quite figure out how to delete all of a posts comments along with deleting the post. ive set up comments as belonging to posts and posts as having many comments and... Post.find(params[:id]).destroy ...works fine i just can''t figure out any way to delete that posts comments as well. comments uses the standard foreign key of post_id. thanks. -- Posted via ruby-forum.com.
In your post.rb file, add :dependent => :destroy.... eg: has_many :comments, :dependent => :destroy On 6/1/06, heman <inthetrunk@gmail.com> wrote:> > i can''t quite figure out how to delete all of a posts comments along > with deleting the post. ive set up comments as belonging to posts and > posts as having many comments and... > > Post.find(params[:id]).destroy > > ...works fine i just can''t figure out any way to delete that posts > comments as well. comments uses the standard foreign key of post_id. > > thanks. > > -- > Posted via ruby-forum.com. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: wrath.rubyonrails.org/pipermail/rails/attachments/20060601/fd4e9f80/attachment.html
perfect, thank you! -- Posted via ruby-forum.com.