Hm, первый раз я вижу это, когда я хочу, чтобы удалить строку: (Я хочу удалить respondent.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
PS
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
Итак, как мы знаем, как вы удаляете строку? Показать код – fl00r
ok.Следующий вопрос. как мы знаем, как вы получаете '@ респондента'? Показать весь код, связанный с вашим делом, добавил человек – fl00r
, надеюсь, вы имели в виду это? – leeroygenehax