quick answer needed on dependancy

You’re trying to invoke a class method ‘mail_template_mailinglists’, which isn’t how habtm works. What you want is to retrieve the MailTemplate object, and ask it whether it has any mailinglists.

Try this (not tested, but should give you how it works):

mail_template = MailTemplate.find(params[:id]) # grab the MailTemplate we're looking to destroy

if mail_template.mailinglists.empty? # see whether it has any mailinglists using it

mail_template.destroy else flash[:notice] = “Cannot delete mail template, as it is being used by one or more mailinglists.” end

HTH!