【发布时间】:2014-10-31 06:54:58
【问题描述】:
所以我有这个问题,我想在我的表单中添加一些标记,除了我的管理面板中的基本表单,我正在为此使用活动管理员。
下面是我的基本表单代码
form do |f|
f.inputs do
f.input :first_name
f.input :last_name
f.input :bio
f.input :description
f.input :affiliate_link
f.has_many :videos, :allow_destroy => true do |video|
video.input :title
video.input :subtitle
video.input :description
video.input :asset, as: :file
video.input :teaser, as: :file, input_html: {class: 'teaser'}
video.input :pdf, as: :file
video.input :categories, collection: Category.where("parent_id is not null")
video.input :tags, as: :check_boxes, wrapper_html: {class: 'checkbox-margin-left'}
end
end
# f.inputs do
# render partial: "shared/templates"
# end
f.actions
end
现在我试图渲染一个部分,希望它会成为整个表单的一部分,但实际上表单消失了,只渲染了部分,所以我认为我应该改变我的策略,这就是我接下来要做的。我创建了一个部分表单。
form :partial => "form"
它呈现了表单,我在部分中添加了我的标记,但我遇到了另一个问题。视频的 has_many 关联不是作为新的记录形式呈现,而是作为选择选项呈现。现在我想知道如何让它呈现一个新的记录表单,为这个关联生成一个新的表单,而不是显示一个选择框。
【问题讨论】:
标签: ruby ruby-on-rails-4 activeadmin