On 20 July 2014 02:00, Mano Svajone <[email protected]> wrote:
> Restaurant Load (1.5ms)  SELECT * FROM "restaurants" INNER JOIN
> "restaurant_branches" ON "restaurant_branches"."restaurant_id" =
> "restaurants"."restaurant_id"
> +----------+---------+---------+---------+----------+---------+----------+---------+---------+---------+---------+---------+---------+---------+---------+-------+
> | resta... | res_... | res_... | crea... | updat... | user_id | resta... | 
> addr...
> | addr... | addr... | addr... | addr... | addr... | numb... | numb... | email 
> |
> +----------+---------+---------+---------+----------+---------+----------+---------+---------+---------+---------+---------+---------+---------+---------+-------+
> | 27       | DOGG... | WE S... | 2014... | 2014-... | 4       | 28       | 
> 405 ...
> |         | CHICAGO | IL      | 60666   | USA     |         |         |       
> |
> | 27       | DOGG... | WE S... | 2014... | 2014-... | 4       | 29       | 
> 111 ...
> |         | CHICAGO | IL      | 60661   | USA     |         |         |       
> |
> +----------+---------+---------+---------+----------+---------+----------+---------+---------+---------+---------+---------+---------+---------+---------+-------+
>
> As you can see, I have two records for record 27. This is from a joined
> table between restaurants and restaurant_branches. How would I approach
> this in a view so that when I select a record on my index.html.erb file
> when it gets routed to the show.html.erb file it'll only take one row of
> that record and only show me one branch instead of 2?

Have you checked by using count whether there are in fact two records
returned and this is not just a figment of the logging?  If there are
two then also include restaurant_branches.id and I think you will find
there are in fact two branches.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsxGkOvm4wV6xDHxJYpXAj250NbrbyM0j9NdAJ91yrHTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to