product_attr_config.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. class ProductAttrConfig < ActiveRecord::Base
  2. has_paper_trail
  3. self.table_name = 'product_attr_configs'
  4. belongs_to :product_attr_key, :foreign_key => :attr_key_id
  5. validates :size_type,presence:true
  6. def show_products
  7. showProducts=[[]]
  8. @products = Product.where("show_flag=1").order("created_at desc")
  9. @products.each do |pd|
  10. a=[pd.id,pd.name]
  11. showProducts.push(a)
  12. end
  13. showProducts.each {|v| puts v}
  14. return showProducts
  15. end
  16. rails_admin do
  17. navigation_label '商品管理'
  18. weight -250
  19. parent ProductAttrKey
  20. nestable_tree({
  21. position_field: :position,
  22. max_depth: 2
  23. })
  24. list do
  25. filters [:product_id,:product_attr_key]
  26. field :id
  27. field :product_id
  28. field :show_products
  29. field :product_attr_key
  30. field :size_type
  31. end
  32. show do
  33. field :id
  34. field :product_id
  35. field :product_attr_key
  36. field :size_type
  37. end
  38. edit do
  39. field :product_id
  40. field :product_attr_key
  41. field :size_type
  42. end
  43. end
  44. end