Wes G. wrote:
So just to be explicit, from class A (backed by database table Table_A),
attempting to relate to class B, (backed by database table Table_B),
joined by model C
has_many :Bs, :through => ‘C’,
:foreign_key => ‘key into Table_A’, :source => ‘B’
?
So there is no reference to the foreign key column from B into C
(unlike the HABTM specification), correct?
Thanks,
Wes
Better yet, let’s be really explicit.
I am trying to relate Job to TargetList through JobListAssociation.
None of the tables have “traditional” Rails naming conventions except
for the join table which happens to have an “id” column.
job.rb:
class Job < ActiveRecord::Base
set_table_name :JobData
set_primary_key :JobReferenceNumber
has_many :target_lists, :through => :job_list_association,
:foreign_key => :JobReferenceNumber,
:source => :target_list
target_list.rb:
class TargetList < ActiveRecord::Base
set_table_name :DataSetInfo
set_primary_key :DataSetID
has_many :jobs, :through => :job_list_association,
:foreign_key => :DataSetID,
:source => :job
job_list_association.rb:
class JobListAssociation < ActiveRecord::Base
set_table_name :DataTables
belongs_to :job, :foreign_key => ‘JobReferenceNumber’
belongs_to :target_list, :foreign_key => ‘DataSetID’
When I attempt to call @current_job.target_lists.include? in my view, I
see:
ActiveRecord::HasManyThroughAssociationNotFoundError in
E_simply#job_params
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/reflection.rb:169:in
check_validity!' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/associations/has_many_through_association.rb:6:ininitialize’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/associations.rb:876:in
`target_lists’
Do I need to add a :condition onto my has_many specification?
Should I always be using symbols instead of strings as hash values in
these ActiveRecord relationship method calls? If so, why?
Thanks,
Wes