Rails - how to move view logic into a helper when iterating through an array of objects -


so in view, displaying prices shirts, belong products category. in view, looking through array of shirts so:

<% @shirts.get_shirts("red", "small").each |shirt| %>   <%= shirt.price "> <% end %> 

this works want, displaying prices shirts red , small.

however, when try move logic corresponding helper, displays full object data instead of prices. helper code below:

def show_prices(color, size) @shirts.get_shirts(color, size).each |shirt|   shirt.price end end 

and calling in view so:

<%= show_prices("red","small") %> 

what doing wrong in helper? seems should same thing not.

result of each method collection. want next helper method

def show_prices(color, size)   @shirts.get_shirts(color, size).map(&:price).join end 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -