product_cat.rb 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 :cow_state
  22. field :products
  23. end
  24. show do
  25. field :id
  26. field :name
  27. field :position
  28. field :ancestry
  29. field :status
  30. field :cow_state
  31. field :products
  32. end
  33. edit do
  34. field :name
  35. field :status
  36. field :cow_state
  37. field :products
  38. end
  39. end
  40. end