0

私は今このコードを持っています。

<div class="alert alert-<%= name == :notice ? "success" : "error" %>">

ただし、「success」、「error」など、この 2 つのほかに「info」、「block」もあります。

残念ながら、`name == :notice' の場合は「成功」でなければなりません。しかし、他のすべてはそのままのようにすることができます

when `name == :error`, it has to be "error"  
when `name == :info`, it has to be "info"  
when `name == :block`, it has to be "block"  

これら4つのオプションを想定して、それらを1行にコーディングするにはどうすればよいですか?

4

1 に答える 1