Хм, Первый раз, когда я вижу это, когда я хочу удалить строку: (Я хочу удалить респондент.email) я получил его:
Mysql::Error: Cannot delete or update a parent row: a foreign key constraint fails (`survey_development`.`inquiries`, CONSTRAINT `inquiries_ibfk_2` FOREIGN KEY (`respondent_id`) REFERENCES `respondents` (`id`)): DELETE FROM `respondents` WHERE `id` = 4
p.s
users (table): id, email
questions (table): id, text
inquiries: question_id, user_id
answers: inquiry_id, text
Модель пользователей:
has_many :inquiries
has_many :questions, :through => :inquiries
has_many :answers, :through => :inquiries
модель вопроса:
has_many :inquiries, :dependent => :destroy
has_many :answers, :through => :inquiries, :dependent => :destroy
модель ответа
belongs_to :inquiry
belongs_to :question
модель запроса
belongs_to :question
belongs_to :users
has_one :answer, :dependent => :destroy
respondents_controller
# DELETE /respondents/1
def destroy
@respondent.destroy
head :ok
end
respondent_model
class Respondent < ActiveRecord::Base
has_many :inquiries
has_many :questions, :through => :inquiries
has_one :answer, :through => :inquiry
end