у меня 4 модели.Я хочу удалить вопрос, но теперь я не могу.Не знаю почему.Я думаю, сначала мне нужно удалить ответ на эти вопросы, затем удалить запрос, а затем вопросы сам.Правильно.Но как я могу это сделать?
там мои модели:
-respondents_model
class Respondent < ActiveRecord::Base
has_many :inquiries
has_many :questions, :through => :inquiries
has_many :answers, :through => :inquiries
end
-answer_model
class Answer < ActiveRecord::Base
belongs_to :inquiry
belongs_to :question
validates_uniqueness_of :inquiry_id
end
-question_model
class Question < ActiveRecord::Base
has_one :answer, :through => :inquiry , :dependent => :destroy
belongs_to :inquiry , :dependent => :destroy
end
-query_model
class Inquiry < ActiveRecord::Base
belongs_to :question
belongs_to :respondent
has_one :answer
end
и мой вопрос_контроллер
def destroy
@question.destroy
head :ok
end