How can I add or append a ruby helper that iterates in an active record response??
I have tried this (with .html or .append):
$( ".result" ).html('<%= @products.each do |product| %><label>product</label><% end %>');
But the problem is that it return all the list of products like this:
productproduct[#<Product id: 35, name: "", price: nil, category: "", quantity: nil, qty_unit: "", company_id: 108, created_at: "2014-11-13 17:22:33", updated_at: "2014-11-13 17:22:33", cost: nil, seller_bonification: nil>, #<Product id: 36, name: "Salmon", price: 3000, category: "Pescado", quantity: 1, qty_unit: "kg", company_id: 105, created_at: "2014-11-13 17:25:27", updated_at: "2014-11-13 17:25:27", cost: nil, seller_bonification: nil>]
So, I get only the string "product" from product and not the iterated object itself, I cant access to each product. And after that, I get all the list of products in a Active Records way. I've also tried this without the "=", like this:
$( ".result" ).html('<% @products.each do |product| %><label>product</label><% end %>');
And I only get:
productproduct
I dont know how to solve this issue. Maybe, a better practice is to use gon gem, or turbolinks, or a hash?? Does anyone knows??