Using Rails 3, but I guess doesn’t matter. I put this in the template helper.
It always goes to the last case badge-warning when I for whatever value I put for rating, such as rating_badge(4):
def rating_badge(rating)
case rating
when rating > 3
'badge-success'
when rating < 3
'badge-important'
else
'badge-warning'
end
end
What went wrong?
You have a stray rating variable at the top of your case statement. The correct syntax is:
This works for me at the REPL using pry and irb.