Hey, I was just wondering what the best practice for this situation would be. I've got two models(word, definition) both with destroy methods in the controllers that just change the model.status to "deleted". In the words controller I'd like it to call the definition_controller destroy method on definition models. And I'm just blanking on how to do this like a regular model method. Would I have to double the destory method in the model? Then I wouldn't be adhering to dry.
// words_controller.rb def destroy begin ActiveRecord::Base.transaction do @word = Word.find(params[:id], :include => :definitions) @word.status = 'deleted' @word.save @word.definitions.each do |h| h.destroy // Actually destorys the record instead of just setting the status to "deleted" end end rescue ActiveRecord::RecordInvalid => invalid flash[:notice] = 'Word was not deleted' render :action => "new" end respond_to do |format| format.html { redirect_to(words_url) } end end // definitions_controller.rb def destroy begin ActiveRecord::Base.transaction do @definition = Definition.find(params[:id]) @definition.status = 'deleted' @definition.save end rescue ActiveRecord::RecordInvalid => invalid flash[:notice] = 'Definition was not deleted' render :controller => :words, :action => "new" end respond_to do |format| format.html { redirect_to(words_url) } end end Thanks, bp --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---