Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Did you know you can pass classes into Rails tag helpers as Arrays?

View gist:999715
1 2 3 4 5 6 7 8 9 10 11
# Let's say you've programatically built up an array of classes for a HTML element:
my_classes = [:a, :b, 'c']
 
# Don't do this, join(" ") is for chumps:
<% content_tag(:p, "Foo", :class => my_classes.join(" ")) %>
 
# Winners do this:
<% content_tag(:p, "Foo", :class => my_classes) %>
# => <p class="a b c">Foo</p>
<% link_to("Foo", foos_path, :class => my_classes) %>
# => <a href="/foos" class="a b c">Foo</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.