1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
>> p = Project.find(2)
p = Project.find(2)
=> #<Project id: 2, desc: "rails", started: nil, ended: nil, coordinator_id: nil, created_at: "2009-02-15 18:58:29", updated_at: "2009-02-15 18:58:29">
>> j_devr = JavaDevelopper.create(:title=>'Mr',:lastname=>'Smith')
j_devr = JavaDevelopper.create(:title=>'Mr',:lastname=>'Smith')
=> #<JavaDevelopper id: 3, type: "JavaDevelopper", title: "Mr", lastname: "Smith", firstname: nil, mail: nil, phone: nil, dept: nil, created_at: "2009-02-15 19:08:23", updated_at: "2009-02-15 19:08:23">
>> p.developpers << j_devr
p.developpers << j_devr
ActiveRecord::HasManyThroughAssociationPolymorphicError: Cannot have a has_many :through association 'Project#developpers' on the polymorphic object 'Developper#developper'.
from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/reflection.rb:284:in `check_validity!'
from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations/has_many_through_association.rb:5:in `initialize'
from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations.rb:1297:in `new'
from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/associations.rb:1297:in `developpers'
from (irb):4
>> devs = Development.new
devs = Development.new
=> #<Development id: nil, project_id: nil, developper_id: nil, developper_type: nil, budget: nil, created_at: nil, updated_at: nil>
>> devs.project = p
devs.project = p
=> #<Project id: 2, desc: "rails", started: nil, ended: nil, coordinator_id: nil, created_at: "2009-02-15 18:58:29", updated_at: "2009-02-15 18:58:29">
>> devs.developper = j_devr
devs.developper = j_devr
=> #<JavaDevelopper id: 3, type: "JavaDevelopper", title: "Mr", lastname: "Smith", firstname: nil, mail: nil, phone: nil, dept: nil, created_at: "2009-02-15 19:08:23", updated_at: "2009-02-15 19:08:23">
>> devs.save
devs.save
=> true |
Partager