宝石 “formtastic”, “〜> 2.1.1” 宝石 “activeadmin”, “〜> 0.4.2” 宝石 “纸夹”
为照片做场在主动管理表单应用程序/视图/管理/产品/ _form.html.erb没有显示,但在应用程序/视图/产品相同的形式/ _form.html.erb产品的意见,工作正常
>应用/管理/ products.erb
ActiveAdmin.register Product do
form :partial => "form"
end
应用程序/视图/管理/产品/ _form.html.erb
<%= semantic_form_for [:admin , @product ], :html => { :multipart => true } do |f| %>
<%= f.semantic_errors :name , :price , :description, :category_id %>
<%= f.inputs :new_product do%>
<%= f.input :name %>
<%= f.input :price %>
<%= f.input :description %>
<%= f.input :category_id , :as => :select , :collection => Hash[Category.all.map{|c| [c.name, c.id]}] %>
<% end %>
<%= f.inputs "Product images" do %>
<%= f.fields_for :prod_images do |p| %>
<%= p.input :photo, :as => :file, :label => "Image",:hint => p.template.image_tag(p.object.photo.url(:thumb)) %>
<%= p.input :_destroy, :as=>:boolean, :required => false, :label => 'Remove image' ,:hint => p.object.new_record? ? p.template.image_tag(p.object.photo.url(:thumb)) : p.template.image_tag(p.object.photo.url(:thumb)) %>
<%end%>
<% end %>
<%= f.actions do %>
<%= f.action :submit , :as => :button %>
<% end %>
<% end %>