jeudi 10 décembre 2015

Returning a query to display ads on side bar

I am working with three tables Salon Treatment and Service. Service is owned by Salon. Service and Treatment have a direct relationship as every Service has a Treatment but not every Treatment has a Service. Treatment holds a variable Category.

I am trying to display results on a side bar of the treatments/showof all Services related to the Treatment they are looking at.

In my application helper I have the following query

def salonAds

@ads = Services.includes(:treatment).where('treatment.category = ?',  Service[:treatment_id])

end

But I know that is wrong.

I am them trying to call a do in my treatments/show

<% @ads.each do |ads| %>
<td><%= ads.description %></td>
    <td><%= ads.price %></td>

   <% end %>

Any solutions or alternatives to how this can be achieved would be much appreciated

Aucun commentaire:

Enregistrer un commentaire