product_cat.rb 928 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. class ProductCat < ActiveRecord::Base
  2. has_paper_trail
  3. self.table_name = 'product_cats'
  4. has_ancestry
  5. has_many :products, :foreign_key => :category_id
  6. validates :name,presence:true
  7. rails_admin do
  8. navigation_label '商品管理'
  9. weight -240
  10. nestable_tree({
  11. position_field: :position,
  12. max_depth: 2
  13. })
  14. list do
  15. filters [:name,:ancestry,:position]
  16. field :id
  17. field :name
  18. field :position
  19. field :ancestry
  20. field :status
  21. field :products
  22. end
  23. show do
  24. field :id
  25. field :name
  26. field :position
  27. field :ancestry
  28. field :status
  29. field :products
  30. end
  31. edit do
  32. field :name
  33. field :status
  34. field :products
  35. end
  36. end
  37. end