Am 27.11.2011 09:57, schrieb Taiwan Vincent:
> 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
>> NorbertYou are quoting my post, where I give you a solution that handles everything with less coding effort in the model, where it belongs... But fiddling around with a hack in the controller, that simply shouldnt do such work. But maybe I am the one who is wrong? Bye Norbert
signature.asc
Description: OpenPGP digital signature

