Why is this embedded ruby code evaluating to nothing?
This code here:
<%= case event.subject.value
when 1
puts " upvoted"
when -1
开发者_运维问答 puts " downvoted"
when 0
puts " removed a vote from"
end %>
does not result in any string being rendered. I tried adding an else
statement just in case event.subject.value
had a different value from 1, -1, or 0, but the code still evaluated to nothing. The code throws no errors...
<%= case event.subject.value
when 1
" upvoted"
when -1
" downvoted"
when 0
" removed a vote from"
end %>
remove puts statement
puts returns nil
. It's side effect is that it outputs to the stdout.
"puts" method outputs to your console( server log ), did you try to remove puts?
Ok I realized what the problem was. I had to remove the puts
from the switch statement.
精彩评论