Hi I got a solution. Here is my destroy function. Many thanks for the
reply.
def destroy
@board = Board.find(params[:id])
@board.posts.destroy_all
@board.destroy
respond_to do |format|
format.html { redirect_to(boards_url) }
format.xml { head :ok }
end
end
On Nov 26, 1:23 am, Norbert Melzer <[email protected]> wrote:
> Am 24.11.2011 15:55, schrieb Taiwan Vincent:
>
> > Could anyone tell me how to destroy all the posts when the board is
> > destroyed?
>
> Take a look at the :dependent option for associations:
>
> <http://guides.rubyonrails.org/association_basics.html>
>
> HTH
> Norbert
>
> signature.asc
> < 1KViewDownload
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.