Here's what the default scaffolding generates:
<%= link_to 'Delete', admin_user, method: :delete, data: { confirm: 'Are you sure you want to delete?' } %>
I want to create a helper method so that I can call a remove_link(admin_user)
and have it behave the same way:
def remove_link(item)
link_to item, method: :delete, :data { confirm: 'Esta seguro que quiere eliminar este registro?' } do
"#{content_tag :i, nil, class: 'icon-remove-sign'}".html_safe
end
end
But I'm getting this error:
SyntaxError in Admin::UsersController#index
/home/sergio/Work/foo/app/helpers/application_helper.rb:11: syntax error, unexpected '{', expecting tASSOC
... item, method: :delete, :data { confirm: 'Esta seguro que qu...
You have a syntax error in the third argument to link_to
, you can use data: foo
or :data => foo
, but not :data foo
link_to item, method: :delete, data: { confirm: 'Esta seguro que quiere eliminar este registro?' } do