Below is the has_many throughout association I am using -
class Test
has_many :findings
has_many :assessments, :through => :findings
class Finding
belongs_to :assessment
belongs_to :test
class Assessment
has_many :findings
has_many :tests, :through => :findings
The data in the Test table is primarily static. When I Create a new
Assessment I want to be able populate the Findings table with all
tests in the Test table, as all tests are mandatory as part of the
assessment.
I can get this to partially work, for example -
a = Assessment.create!(:name => 'assessment1', :test_ids => ['1', '2',
'3'])
mysql>select * from FINDINGS;
+----+---------------+----------------------+-------+----------
+---------+
| id | test_id | assessment_id | pass | fail | verdict
|
+----+---------------+----------------------+-------+----------
+---------+
| 1 | 1 | 1 | NULL | NULL |
NULL |
| 2 | 2 | 1 | NULL | NULL |
NULL |
| 3 | 3 | 1 | NULL | NULL |
NULL |
But I cannot figure out how to supply all Test id's to create the full
set of tests in the Findings table
Any help much appreciated!
Thanks
But I cannot figure out how to supply all Test id's to
create the full
set of tests in the Findings table
Can you please specify what you need to populate in finding table. as
you have mentioned that you need to specify test ids in finding table
that is already get achieved with the way you followed to populate
findings table.
Please provide details.
Thanks,
Piyush
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.