In my Rails app, I have a store with products and users. Both of those have models and controllers. What I want to achieve is to show on a view template a product to a current_user based on the attribute from a model that he has. For an example if a user has "Female" attribute from user model, and then to show some products related to this attribute. How can I achieve this?
These are my product views where all products are showed:
<% @products.each do |product| %>
<%= render "product_row", product: product, order_item: @order_item %>
<% end %>
_product_row.html.erb
<h4><%= product.name %></small></h4>
<div class="image">
<%= image_tag product.image.url(:original), class: "img-responsive" %></div>
<p>Some description.</p>
<a href="/bag/<%= product.id %>", class="add-to-cart">Add to Package</a>