On Thursday, July 23, 2015 at 2:15:02 PM UTC-7, [email protected] wrote:
>
> Everything has been going well in my upgrade, 1 project done and a couple 
> to go.  However, I've poured through the associations info in the 
> documentation and narrowed in on this one 
> <http://sequel.jeremyevans.net/rdoc/files/doc/association_basics_rdoc.html#label-many_to_many+and+one_through_one>.
>  I'm 
> having a hard time making my queries and models jive with the generated 
> migration file (a "common query" generator would be awesome).  The 
> migration came from a schema that was originally made by DataMapper.  
>
> This gist <https://gist.github.com/Nogbit/45b21c2c9c5340cc1afd> has all 
> the necessary code with the goal being........with *person.rb* and 
> *group.rb* have a query that works in *query.rb*.  The migration that is 
> used is* 001_migration.rb* which had its tables originally generated from 
> the classes in *original_datamapper_classes.rb* (which also has the 
> original DataMapper query).  
>
> While I get the error noted in *query.rb*, I believe that error to not be 
> in the right context because either the query itself is wrong, or, my 
> associations are wrong in the models.  Please advise if you have the time.
>

You are using composite primary key on Group, so you have to use composite 
association keys:

Person.many_to_many  :groups,
       :left_key=>:person_id,
       :right_key=>[:group_id, :group_school_id],
       :join_table=>:group_people

Group.many_to_many :people,
       :left_key=>[:group_id, :group_school_id],
       :right_key=>:person_id,
       :join_table=>:group_people

That should hopefully fix it.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to