I will destroy my user with a HTML link, but it doesn\'t seem to generate the correct link, what am i doing wrong?
public function destroy($id)
{
//Slet
Another "clean" solution is to make it the Rails way as described here:
Create a new .js file in public and write this function:
$(function(){
$('[data-method]').append(function(){
return "\n"+
"\n"
})
.removeAttr('href')
.attr('style','cursor:pointer;')
.attr('onclick','$(this).find("form").submit();');
});
Don't forget to include the .js file in your template after including jQuery.
Use classic link_to() or link_to_method() functions to create links to delete records. Just remember to include the "data-method"="DELETE" parameter:
{{ link_to_route('tasks.destroy', 'D', $task->id, ['data-method'=>'delete']) }}
What I like about this that it seems much cleaner than bloating your code with Form::open(); in blade templates.