Cameron Bass Cameron Bass - 7 months ago 78
HTML Question

html/rails form. Input

This is a simple question but I can't seem to find a solid answer. I simply want to know if this is valid? it's a basic form_for with in input at the bottom.

## Form

<%= form_for @snitch, html: { class: "form-actions", method: 'delete' } do |form| %>
<span class="button-text"><%= link_to 'NO WAY!', home_base_url_or_default(root_path), rel: "modal:close" %></span>
<button type="submit" class="button button--modal delete-snitch" data-snitch-id="<% @snitch.token %>" value="Yes, delete it.">
<% end %>

Is the third line valid? specifically where it says
data-snitch-id="<% @snitch.token %>"
? if it is not. can someone help me figure out how I can do something like that?


HTML data attributes are perfectly valid and widely supported. They're used to store custom data in an element. You can create elements with those attributes in rails helpers as well.

<%= button_tag "Yes, delete it.", type: :submit,
    data: {"snitch-id" => @snitch.token}, 
    class: 'button button--modal delete-snitch' %>

The only problem with your example is that you're not printing the value of @snitch.token. You should be using <%= @snitch.token %> instead of <% @snitch.token %>