一个关于ruby的代码的问题!

下面的代码是在rhtml中的

<b><%= c_type = visible_name(c.contributable_type); icon(c.contributable_type.to_s, nil, nil, c_type, c_type) %>

改成

<b><%= c_type = visible_name(c.contributable_type); icon(c.contributable_type.to_s, nil, nil, c_type,( c_type)) %>

 

在蓝色的括号里做一个判断,如果目前变量c_type的值是A,就将其转化成xx,是B转化成yy,是C转化成zz

我不是是很懂rbuy语言,请大家帮忙,谢谢了!

 

 

 

[code="ruby"]
<%= c_type = visible_name(c.contributable_type); icon(c.contributable_type.to_s, nil, nil, c_type,get_value(c_type)) %>
[/code]

helper中
[code="ruby"]
def get_value(c_type)
case c_type
when "A"
return "XX"
when "B"
return "YY"
end
end
[/code]

写个helper吧