Skip to content

Instantly share code, notes, and snippets.

@javan
Created July 3, 2013 19:17
Show Gist options
  • Save javan/5921866 to your computer and use it in GitHub Desktop.
Save javan/5921866 to your computer and use it in GitHub Desktop.
Supplying data-* html attributes as a hash with Rails helpers.

Just OK

link_to(person.name, person_path(person), "data-thing" => 1, "data-other-thing" => true)

<a data-other-thing="true" data-thing="1" href="/people/127326141-david-heinemeier">David Heinemeier Hansson</a>

Awesome!

link_to(person.name, person_path(person), data: { thing: 1, other_thing: true })

<a data-other-thing="true" data-thing="1" href="/people/127326141-david-heinemeier">David Heinemeier Hansson</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment