• (function(){
      $.rails.allowAction =  function(element) {
        var message = element.data('confirm'),
            answer = false, callback;
        if (!message) { return true; }
    
        if (rails.fire(element, 'confirm')) {
          try {
            answer = rails.confirm(element);
          } catch (e) {
            (console.error || console.log).call(console, e.stack || e);
          }
          callback = rails.fire(element, 'confirm:complete', [answer]);
        }
        return answer && callback;
      }
    
    
    
      $.rails.confirm = function(element) {
        var id = 'modalConfirm',
            w = element.data('width'),
            h = element.data('height'),
            title = element.data('title') || '系统提示',
            text = element.data('confirm') || '确定删除?',
            type = text ? 'text' : 'iframe',
            remote = !! element.data('remote');
        var target_str = element.attr('target') ? ' target="'      + element.attr('target') + '"' : '';
        var method_str = element.data('method') ? ' data-method="' + element.data('method') + '"' : '';
    
        var html = '<div class="modal fade" id="' + id + '"  tabindex="-1" role="dialog" aria-labelledby="modalConfirmLabel" aria-hidden="true">' +
            '<div class="modal-dialog" style="width: ' + w + 'px;">' +
            '<div class="modal-content">' +
            '<div class="modal-header">' +
            '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">关闭</button>' +
            '<h4 class="modal-title" id=" ' + id + ' " >' + title + '</h4>' +
            '</div><form role="form" action="" method="">';
    
        html += '<div class="modal-body">' + '<div class="form-group text-center">' +
            '<p>' + text + '</p></div></div>';
    
        html += '<div class="modal-footer">';
        href = remote ? 'javascript:' : element.attr('href');
        html += '<a href="' + href + '"' + target_str + method_str + ' class="btn btn-green" id="pop-confrim-submit">确定</a>';
        html += '<button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>';
        html += '</div></form>';
        html += '</div>';
        html += '</div></div></div>';
    
        $('#' + id).remove();
        $("body").append(html);
        $('#' + id).modal('show');
        if (remote) {
            $('#modalConfirm-submit').click(function(event) {
                event.preventDefault();
                $.rails.handleRemote(element);
                $(this).next().click();
                if (element.data('callback')) {
                    eval(element.data('callback'));
                }
                return false;
            });
        }
        if (target_str) {
            $('#modalConfirm-submit').click(function(event) {
                $(this).next().click();
            });
        };
        return false;
      };
    
    }())
    

    这个 method: :delete 走的 GET 动作

  • 
    <%=link_to "删除",user_path(user) , :data => { confirm: "确定删除?",method: "delete"}%>
    
    

    这个链接走的是 GET 动作,也就是 show, 这个怎么破啊