2013-05-28 26 views
0

我有訂單模型。我正在使用活動管理員,並且我不確定問題是否因爲此問題,但是當我去編輯我的訂單時,編輯頁面是空白的,沒有我爲該訂單存儲的先前數據。另一個問題可能是同樣的問題,那就是當我從編輯頁面填寫訂單時,它會創建一個新的訂單。在這一刻我只有views/admin/orders/form,我還沒有編輯視圖。我應該有嗎?編輯表單正在顯示,但訂單未被傳遞到表單

我在與此相關的路線中沒有任何東西。

順序控制器

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 


    %> 
+0

你可以從你的控制器,視圖和routes.rb添加部分代碼嗎? – Parandroid

回答

0

在我的形式在第2行我改成semantic_form_for [:admin, resource], :builder => ActiveAdmin::FormBuilder do |f|

相關問題