2011-11-22 20 views
7

यह तीसरा दिन है जब मैं सक्रिय व्यवस्थापक पर क्रश कर रहा हूं।क्या सक्रिय व्यवस्थापक में गहरी घोंसला करना संभव है?

मेरे पास @survey है जो has_many :questions और प्रत्येक प्रश्न has_many :answers - वे वास्तव में वेरिएंट उपयोगकर्ता चुन सकते हैं।

लेकिन फिर भी मैं इसे काम पर नहीं डाल सकता, यह सिर्फ 1 स्तर: पर गहराई से कुछ भी नहीं बनाता है, यहां तक ​​कि फ़ॉर्म ठीक से काम करता है, लेकिन कुछ भी नहीं बनाया गया है।

+0

अपने मॉडल में कोड चिपकाएं और आपके सक्रिय व्यवस्थापक संसाधन कार्यान्वयन – JCorcuera

+1

इस ActiveAdmin समस्या में टिप्पणी देखें। और "नेस्टेड" युक्त अन्य मुद्दों। https://github.com/gregbell/active_admin/issues/478 और यहां भी देखें: http://stackoverflow.com/questions/8224884/nested-form-in-active-admin – slothbear

+0

यह भी मेरा प्रश्न है *)) – prikha

उत्तर

14

मेरे पास निम्न क्लिक्स कोर्स-> अनुभाग-> सबक हैं।

form do |f| 
    f.inputs "Details" do 
    f.input :instructor, :as => :select 
    f.input :title 
    f.input :name 
    f.input :price 
    f.input :discount 
    f.input :slug 
    f.inputs "Sections" do 
     f.has_many :sections, :header=>"" do |section| 
     section.input :name 
     section.input :position 
     if section.object.id 
      section.input :_destroy, :as=>:boolean, :required => false, :label=>'Remove' 
     end 

     section.has_many :lessons, :header=>"Lessons" do |lesson| 
      lesson.input :title 
      lesson.input :position 
      lesson.input :duration 
      lesson.input :_destroy, :as=>:boolean, :required => false, :label=>'Remove' 
     end 
     end 
    end 

    end 
    f.buttons 
end 

मेरे मॉडल निम्न हैं::

class Course < ActiveRecord::Base 
    has_many :sections, :dependent => :delete_all 
    accepts_nested_attributes_for :sections, :allow_destroy => true 
    attr_accessible :sections_attributes 
.... 

class Section < ActiveRecord::Base 
    belongs_to :course 
    has_many :lessons, :dependent => :delete_all 
    attr_accessible :course_id, :name, :position 
    accepts_nested_attributes_for :lessons, :allow_destroy => true 
    attr_accessible :lessons_attributes 
.... 

class Lesson < ActiveRecord::Base 
    belongs_to :section 
    attr_accessible :duration, :position, :section_id, :title 
.... 

और यह महान काम करता है

मैं निम्नलिखित किया! मुझे नहीं पता कि क्या होता है यदि मैं अधिक स्तरों को गहरा करता हूं।

+2

अच्छा! मैंने पहले ही इसे हल कर लिया है। लेकिन उम्मीद है कि यह किसी और की मदद करता है !!! – prikha

+1

@tony अगर हम एचएबीटीएम एसोसिएशन का उपयोग कर रहे हैं ??? हमें क्या करना है? –

+1

रेल के लिए कोई अद्यतन 4? ऐसा लगता है कि सुरक्षित गुण अब नियंत्रक में सेट हैं। हमें 'permit_params' का उपयोग करने की आवश्यकता है? – Defoncesko

संबंधित मुद्दे