I'm searching for some idea how to let the stars view like on this example:
Right now, I have a table with a column for the black stars and a column for the grey stars.(in "Hüllenkontrolle" for example a "2" for 2 black stars and "4" for 4 grey stars). So I thought about something that shows another picture depending on which number is in the database (1 = 1 Star, 2 = 2 stars, 3 = 3 stars, 4 = 4 stars...)
I have no idea what to search on internet or how to realize that not the numbers will be viewed but some stars. Has anybody any idea how to implement this?
some information about my database model: http://img6.imagebanana.com/img/kwenevyz/beziehungen.png
<%= expected_qualification.qualificationstars %> <% @employee.position.expected_qualifications.each do |expected_qualification| %>
Some good news! This seems to work
<% @employee.position.skills.zip(@employee.position.expected_qualifications, @employee.current_qualifications).each do |skill, expected_qualification, current_qualification| %>
<p>
<% (current_qualification.istqualifikation).times do %>
<%= image_tag("black.png") %>
<% end %>
<% (expected_qualification.sollqualifikation - current_qualification.istqualifikation).times do %>
<%= image_tag("grey.png") %>
<% end %>
</p>
<% end %>
This is how it looks in browser now:
If you have an image file each for a black and grey star, try something like this in your view:
<% @employee.position.expected_qualifications.each do |expected_qualification| %>
<% @employee.current_qualification.qualificationstars.times do %>
<%= image_tag("black_star.png") %>
<% end %>
<% [expected_qualification.qualificationstars - @employee.current_qualification.qualificationstars].times do %>
<%= image_tag("grey_star.png") %>
<% end %>
<% end %>
EDIT:
The images go into "public/images" (Rails < 3.1) or "app/assets/images" (Rails 3.1)
EDIT 2: Using your model names.
(I'd suggest renaming "qualificationstars" to simply "stars" in your DB. qualification.qualificationstars is redundant and a bit cumbersome.)