2022-06-08 Rails class_names(token_list)
Rails class_names(token_list)
Rails 6.1 introduces class_names helper | BigBinary Blog
Rails v6.0
<li class="<%= current_page?(dashboards_path) ? 'active' : '' %>"> <%= link_to "Home", dashboards_path %> </li>
Rails v6.1
<li class="<%= class_names(active: current_page?(dashboards_path)) %>"> <%= link_to "Home", dashboards_path %> </li>
class_names は token_list のエイリアス
ActionView::Helpers::TagHelper | RailsDoc(β)
token_list("foo", "bar")
# => "foo bar"
token_list("foo", "foo bar")
# => "foo bar"
token_list({ foo: true, bar: false })
# => "foo"
token_list(nil, false, 123, "", "foo", { bar: true })
# => "123 foo bar"