lundi 14 décembre 2015

get items unique for a list using joins in ruby on rails

This is my query

SELECT lists.id, items.id FROM `lists` LEFT JOIN items ON lists.id = items.list_id

I have three lists and list 1 has three items then in rails it gives me three tables of the form

**list1  list1  list1**         
item1  item1  item1
item2  item2  item2
item3  item3  item3

That means it is looping according to the number of items Is there any way in rails that i can create an array in erb file itself and can put a check for if record already exists?

Aucun commentaire:

Enregistrer un commentaire