Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BuitineKeramika < ActiveRecord::Base
- #set_table_name "buitine_keramika"
- has_many :radinio_tipas, :as => :tipas
- end
- class Radinys < ActiveRecord::Base
- #set_table_name "radinys":radinio_tipas, :class_name => "RadinioTipas"
- has_many :radinio_tipas, :class_name => "RadinioTipas"
- has_one :adresas
- end
- class RadinioTipas < ActiveRecord::Base
- #set_table_name "radinio_tipas"
- belongs_to :radinys
- belongs_to :tipas, :polymorphic => true
- end
- # migration
- create_table :radinio_tipas do |t|
- t.column "radinys_id", :integer
- t.column "tipas_id", :integer
- t.column "tipas _type", :string
- end
- # bandau vykdyti sitoki koda:
- @keramika = BuitineKeramika.new()
- @radinys.radinio_tipas.create(:tipas => @keramika)
Add Comment
Please, Sign In to add comment