0

도움이 필요합니다! 나는 조사를 위해이 개 모델을 가지고 :Active Admin의 중첩 된 양식

다음과 같이 질문에 대한 모델이 있습니다
class Poll < ActiveRecord::Base 

has_many :poll_questions, :dependent => :destroy 
accepts_nested_attributes_for :poll_questions, :reject_if => lambda { |a| a[:text].blank? }, :allow_destroy => true 

end 

는 (이들 assocciations이 올 것 같다) 활성 관리자에서 또한

class PollQuestion < ActiveRecord::Base 
belongs_to :poll 
has_many :poll_answers, :dependent => :destroy 
accepts_nested_attributes_for :poll_answers, :reject_if => lambda { |a| a[:text].blank? }, :allow_destroy => true 

end 

:

ActiveAdmin.register Poll do 
form do |f| 
f.inputs "Main poll" do 
    f.input :title 
    f.input :description 
end 

f.inputs do 
f.has_many :poll_questions do |question| 
    question.input :text 
end 
end 

f.buttons 
end 

end 

실제 질문 개체를 생성하지 않는 아름다운 형태가 있습니다! 왜? 문제를 해결하기 위해 최선을 다했지만 실패했습니다.

답변

0

아마도 accepts_nested_attributes_for에 대해 두 가지 수준이 있기 때문일 수 있습니다. 많은 설문 조사 응답이있는 설문 조사 응답을위한 새로운 모델을 만드는 것이 어떻습니까?

그런 다음 PollResponse 클래스 내에 accepts_nested_attributes_for : poll_answers를 설정합니다.

그런 다음 양식 문제를 분류 할 수있을뿐만 아니라 설문에 응답 한 사람 (잠재적)과 설문 응답이 작성된 시간을 추적 할 수 있습니다. PollResponses 모델은 설문 조사에 속해 있어야 설문 조사를 구별 할 수 있습니다. 객체를 생성하여

+0

어떤 대답 변종을 만드는 방법에 대한? 관리자 패널 에서요? – prikha

+0

작동하지 않습니까? [Ryan's Episode] (http://railscasts.com/episodes/196-nested-model-form-part-1)에 적극적인 관리자가 있습니까? – prikha

+0

누군가가 해결책을 가지고 있다면 나는 또한 관심이있다 ... –

0

시도,

f.has_many :poll_questions, PollQuestion.new do |question| 
    question.input :text 
end