mardi 30 août 2016

fetch data from db based on static set in rails

I want to fetch data from db based on static set in rails

{
data: ['data1','data2']
}

I have a data table with column values from the static data

id| Name|

1 | data1

2 | data2

3 | data3

I have another table which is related to the data table and spl_value column

id | data_id | spl_value

1  |   1     |   x

2  |   2     |   x

3  |   2     |   y

4  |   4     |   z

How do i fetch spl_value from the static data?

The expected Result is

id | Name    | spl_value

1  |   data1 |   x

2  |   data2 |   x

3  |   data3 |   y

Rails Version is 3

Aucun commentaire:

Enregistrer un commentaire