ruby on rails - Has_Many :Through or :finder_sql -


I have been moved in whatever I want, but I do not think it's a rail designer looking for Basically, I have to set different pluralization (/ etc issues):

Human relationships (parent, lineage)

I try to get all offsprings for a single parent I am doing, and single parent for many offsprings (only one parent per line is concerned)

I can do this in the following manner in the model:.

  has_one: parent ,: through = gt; : Relation,: foreign_key => : Human_ID ,: Source = & gt; : Source_human has_many: offsprings ,: finder_sql = & gt; 'Select different offspring. * 'Join in the relationships of the offspring of humans' + 'r.human_id = offsprings.id where r.source_human_id = # {id}'   

I had to do this , Because it's a good way to do it:

  is_im: offspring, by = = : Relation,: foreign_key => : Source_human_id ,: source = & gt; : Human   

This is not possible because the foreign key has not been taken to the pass_ campaign (according to the document here)

However, now I am getting this error :

Reversal Warning: String-based interpolation of association conditions has been removed. Please use a proc instead, therefore, for example, has_many: older_friends ,: conditions = & gt; 'Age & gt; # {Age} 'should be changed to has_many: older_friends ,: conditions = & gt; Proc {"age and gt; # {age}"} (Irb_binding is called by (IRB): 1)

However, there is no matter how I hack: situations here, do not look like: finder_sql part Want to take any idea?

If you do then

  has_many: offsprings, finder_sql = & Gt; Proc {"Select different offspring." + "Join INNER relationships from the offspring of humans" + "r.human_id = offsprings.id where r.source_human_id = # {id}"}    

Comments