Queries with multiple joins in ruby on rails

2

I want to do in ruby on rails, this:

SELECT * FROM isolateds 
  INNER JOIN genes ON geness.isolated_id = isolateds.id
  INNER JOIN stats ON stats.gene_id = genes.id
  INNER JOIN mutations ON stats.mutation_id = mutations.id

When I do:

Isolated.joins(:genes).all , the result is:

SELECT * FROM isolateds 
  INNER JOIN genes ON geness.isolated_id = isolateds.id

But when I do, Isolated.joins(:genes, :stats).all , give me an error and I can not get to the table mutations, what am I doing wrong?

    
asked by anonymous 17.04.2015 / 23:52

1 answer

0

I've got enough just to do:

Isolated.joins(:drugs, genes: :mutations ).all

Now my problem is not showing me all of the tables, it has only two columns, can someone explain why? I would like, even if for a certain isolate, if there were no gene appearing in it.

    
18.04.2015 / 00:24