ruby-on-rails – 是否可以在活动管理中进行深度嵌套?
发布时间:2020-12-17 04:20:40 所属栏目:百科 来源:网络整理
导读:这是我在Active Admin上碾压的第三天. 我有@survey has_many:问题和每个问题has_many:答案 – 它们实际上是用户可以选择的变体. 但是我仍然不能把它付诸实践,它只是没有创造更深层次的1级: 即使表单正常工作,但没有创建. 解决方法 我有以下条款课程 – 章
这是我在Active Admin上碾压的第三天.
我有@survey has_many:问题和每个问题has_many:答案 – 它们实际上是用户可以选择的变体. 但是我仍然不能把它付诸实践,它只是没有创造更深层次的1级: 解决方法
我有以下条款课程 – >章节 – >课程.
我做了以下事情: 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,: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 .... 而且效果很棒!我不知道如果我更深层次会发生什么. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |