Guest User

Untitled

a guest
Apr 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. class BuitineKeramika < ActiveRecord::Base
  2. #set_table_name "buitine_keramika"
  3. has_many :radinio_tipas, :as => :tipas
  4. end
  5.  
  6.  
  7. class Radinys < ActiveRecord::Base
  8. #set_table_name "radinys":radinio_tipas, :class_name => "RadinioTipas"
  9. has_many :radinio_tipas, :class_name => "RadinioTipas"
  10. has_one :adresas
  11. end
  12.  
  13.  
  14. class RadinioTipas < ActiveRecord::Base
  15. #set_table_name "radinio_tipas"
  16. belongs_to :radinys
  17. belongs_to :tipas, :polymorphic => true
  18. end
  19.  
  20. # migration
  21. create_table :radinio_tipas do |t|
  22. t.column "radinys_id", :integer
  23. t.column "tipas_id", :integer
  24. t.column "tipas _type", :string
  25. end
  26.  
  27. # bandau vykdyti sitoki koda:
  28.  
  29. @keramika = BuitineKeramika.new()
  30. @radinys.radinio_tipas.create(:tipas => @keramika)
Add Comment
Please, Sign In to add comment