Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. class Compra < ActiveRecord::Base
  2.  
  3. belongs_to :bidon
  4. belongs_to :proveedor
  5. belongs_to :conductor
  6. belongs_to :user
  7. has_many :item_compras, :dependent => :destroy
  8. accepts_nested_attributes_for :item_compras,
  9. reject_if: RejectDeeplyNested.blank?,
  10. :allow_destroy => true
  11. end
  12.  
  13. class ItemCompra < ActiveRecord::Base
  14. belongs_to :compra
  15. belongs_to :product
  16. belongs_to :calibre
  17. end
  18.  
  19. class Product < ActiveRecord::Base
  20. has_many :item_compras, :dependent => :restrict_with_error
  21. end
  22.  
  23. class Calibre < ActiveRecord::Base
  24. has_many :item_compras
  25.  
  26. def to_s
  27. "#{numero}"
  28. end
  29. end
  30.  
  31. create_table "item_compras", force: :cascade do |t|
  32. t.integer "compra_id"
  33. t.integer "product_id"
  34. t.integer "calibre_id"
  35. t.integer "cantidad_bidon"
  36. t.text "nota"
  37. t.datetime "created_at", null: false
  38. t.datetime "updated_at", null: false
  39. end
  40.  
  41. create_table "calibres", force: :cascade do |t|
  42. t.integer "numero"
  43. t.datetime "created_at", null: false
  44. t.datetime "updated_at", null: false
  45. end
  46.  
  47. create_table "products", force: :cascade do |t|
  48. t.string "name"
  49. t.text "descripcion"
  50. t.integer "stock", default: 0
  51. t.datetime "created_at", null: false
  52. t.datetime "updated_at", null: false
  53. end
  54.  
  55. create_table "compras", force: :cascade do |t|
  56. t.integer "proveedor_id"
  57. t.integer "bidon_id"
  58. t.integer "conductor_id"
  59. t.string "state", default: "nueva_compra"
  60. t.float "gastos", default: 0.0
  61. t.integer "numero_camion", default: 0
  62. t.integer "mic", default: 0
  63. t.integer "factura", default: 0
  64. t.integer "total_for_kg"
  65. t.float "total_compra"
  66. t.integer "total_bidones"
  67. t.integer "user_id"
  68. t.float "total_deuda", default: 0.0
  69. t.datetime "created_at", null: false
  70. t.datetime "updated_at", null: false
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement