Skip to content

Instantly share code, notes, and snippets.

@andywenk
Created August 27, 2012 19:54
Show Gist options
  • Save andywenk/3491753 to your computer and use it in GitHub Desktop.
Save andywenk/3491753 to your computer and use it in GitHub Desktop.
order items
ActiveAdmin.register OrderItem do
form do |f|
f.inputs do
f.input :order_id,
:as => :select,
:collection => Order.all.map { |order| order.id }
f.input :product_id,
:as => :select,
:collection => Product.all.map { |product| [product.name, product.id] }
f.input :quantity
end
f.buttons
end
show do |order_item|
attributes_table do
row :id
row :order_id do
link_to(order_item.order_id, admin_order_path(order_item.order_id))
end
row :product_id do
product = Product.find(order_item.product_id)
link_to("#{product.name}", admin_product_path(order_item.product_id))
end
row :quantity
row :created_at
row :updated_at
end
active_admin_comments
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment