似乎@original_id
并且comment.id
必须转换为字符串才能比较相等,当我不将它们转换为字符串时,else
会返回分支中的字符串。为什么是这样?有没有办法绕过它?
- if @original_id.to_s == comment.id.to_s
= "Matched"
- else
= "hi"
语境:
.comment{:class => "c" + nesting.to_s}
.profile
%img{:src => "/assets/profile_image_sample.jpg"}
.message
.username
- if comment.user.username.blank?
= comment.user.first_name
- else
= comment.user.username
= comment.content
.reply-link
= link_to "Reply to comment...", post_path(:original_id => comment.id)
= @original_id.to_s + "and" + comment.id.to_s
- if @original_id.to_s == comment.id.to_s
= "Matched"
- else
= "hi"
- if comment.replies.count > 0
- nesting = nesting + 1
- comment.replies.each do |comment|
= render "comment", :comment => comment, :nesting => nesting