Tengo las siguientes clases Curso-> Secciones-> Lecciones.
hice lo siguiente:
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
Mis modelos son los siguientes:
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
....
y funciona muy bien! No sé lo que sucederá si voy más profundo.
Pegue el código en sus modelos y su implementación de recursos de administración activa – JCorcuera
Consulte los comentarios en este número de ActiveAdmin. Y otros problemas que contienen "anidados". https://github.com/gregbell/active_admin/issues/478 Y mira también aquí: http://stackoverflow.com/questions/8224884/nested-form-in-active-admin – slothbear
esa es también mi pregunta *))) – prikha