I’ve been attempting to find a solution to this problem for about the last 12 hours and simply have to admit defeat and ask the question…
I am currently working on a project which involves added a start rating feature to a product.
the_number = number_with_precision(product.no_of_stars, :precision => 0) gives me the average star rating for the product. I can display the number (eg 4) on the index.html.erb page but cannot for the life of me get it to render a star jpg for for each number (instead of the number).
I am aware of the difference between <%= and <% etc however because this is my first post, I’m unable to copy and past the code I’ve used 🙁
SO… the_number (for example) would give me 4, however the following loop construct within my index.html.erb file keeps throwing an error reading
undefined methodtimes for “4”:ActiveSupport::SafeBuffer`
the_number.times do
img src="my-image.jpg" alt=""
end
I understand the snippet above is not wrapped in the correct tags, but as explained before, it will not allow me too. Please assume that the 1st and 3rd line are wrapped in ruby tags without the ‘=’ and the image is wrapped in the relevant html img tag. You can also assume that the rating ‘system’ works correctly.
Any help would be greatly appreciated 🙂
Thanks
1 Answer