我有一个订单模型。我正在使用活动管理员,我不确定问题是否是因为它,但是当我去编辑我的订单时,编辑页面是空白的,没有我为该订单存储的先前数据。另一个可能是同一个问题的问题是,当我从编辑页面填写订单时,它会创建一个新订单。目前我只有视图/管理员/订单/表单,我还没有构建编辑视图。我应该有一个吗?
我在与此相关的路线中没有任何内容。
订单控制器
ActiveAdmin.register Order, :sort_order => "end_date_asc" do
controller.authorize_resource
menu :label => "All Orders", :parent => "Sales", :priority => 2
scope_to :current_user
filter :name, label: "Order Name"
filter :order_category, label: "Order Category"
filter :order_type, label: "Order Type"
filter :order_status, label: "Order Status"
filter :order_priority, label: "Order Priority"
filter :customer, label: "Customer"
filter :start_date, label: "Start Date"
filter :end_date, label: "Due Date"
filter :id, label: "Order ID#"
index do |order|
column "ID" do |order|
link_to order.id, admin_order_path(order)
end
column "Proof" do |order|
image_tag order.proof_url(:proof).to_s
end
column "Order Name" do |order|
link_to order.name, admin_order_path(order)
end
column(:customer, :sortable => :customer_id)
column "Category", :order_category
column "Status", :order_status
column "Priority", :order_priority
column "Due Date", :end_date
default_actions
end
# TODO: Form is displaying, but order is not being passed to the form
# reference: sprintapp admin_users.rb
# Create/Edit Form
form :partial => "form"
show :title => :name do
panel "Order Details" do
attributes_table_for resource do
row :id
row :assignee_id
row :name
row :order_category
row :order_type
row :order_status
row :order_priority
row :start_date
row :end_date
end
end
resource.line_items.each do |a|
text_node(render :partial => "admin/line_items/show", :locals => { :line_item => a })
end
panel "Printing Details" do
attributes_table_for resource do
row :print_location
row :color_front
row :color_back
row :color_sleeve
row(:artwork) do
image_tag order.artwork_url(:thumb).to_s
end
row(:proof) do
image_tag order.proof_url(:thumb).to_s
end
end
end
end
action_item :only => [:edit, :show] do
form :partial => "form"
end
end
订单
<%=
semantic_form_for [:admin, @orders, current_admin_user.orders.build], :builder => ActiveAdmin::FormBuilder do |f|
f.inputs "Order Information" do
f.input :customer_id, as: :select, :collection => Customer.all, hint: "You need to create a customer before filling out the order form."
f.input :order_category_id, as: :select, :collection => OrderCategory.all, label: "Category", as: :select, hint: "IE: Screen Printing, Embroidery, etc."
f.input :order_type_id, as: :select, :collection => OrderType.all, label: "Type", as: :select, hint: "IE: New, Re-oreder, etc."
f.input :order_status_id, as: :select, :collection => OrderStatus.all, label: "Status", as: :select, hint: "IE: New, art, screens, etc."
f.input :order_priority_id, as: :select, :collection => OrderPriority.all, label: "Priority", as: :select, hint: "IE: 2-day Rush, 3-day Rush, standard, etc."
f.input :start_date, label: "Start Date", as: :datepicker, hint: "Usually, this is the day you enter the order, but you could put a future date."
f.input :end_date, label: "Due date", as: :datepicker, hint: "Put the date in which your order is due."
f.input :name, label: "Order Name", hint: "This is the name of the order."
end
f.inputs "Line Items" do
render :partial => "admin/line_items/form", :locals => { :form => f }
end
f.inputs "Printing Details" do
f.input :print_location_id, as: :select, :collection => PrintLocation.all, as: :select, hint: "Select the location of the print. This should be set up by the admin specific to your companies needs."
f.input :color_front, hint: "List the colors to be printed on the front."
f.input :color_back, hint: "List the colors to be printed on the back."
f.input :color_sleeve, label: "Color side", hint: "List the colors to be printed on the side."
f.input :artwork, hint: "Upload the artwork for this order"
f.input :proof, hint: "This is for art department use only!"
end
f.buttons
end
%>