私はこの小さなヘルパーメソッドを書きました:
def alert_color(name)
if name == 'notice'
return 'alert alert-dismissable alert-success'
end
end
私のアプリケーションのレイアウトでは、次のように書きました。
<% flash.each do |name, msg| %>
<div class=<%= alert_color(name) %>>
<button type="button" class="close" data-dismiss="alert">×</button>
<strong><%= name %></strong><%= msg %>
</div>
<% end %>
私の最初の問題は、名前が helper_method に正しく渡されないため、何とか機能しないことです!
そして2番目の問題は、私が試したことです:
alert_color('notice')
そしてそれはこれを返しました:
<div class="alert" alert-success="" alert-dismissable="">
この動作を変更する方法が本当にわかりません!
そして、私はこの方法でフラッシュメッセージを生成しています:
notice: 'User was successfully updated.'