简体   繁体   中英

SystemStackError - Stack Level Too Deep

I know there are a lot of System Stack Error Questions on here... but everyone of the questions and answers are Unique. and haven't found one that is close to mine.

I really don't see why i am getting this error...

I dont need a view because form is being sent thru ajax. I verified my coding works for inserting the new record with rails console.

i verified the route:

request_user POST  /users/:id/request(.:format)   users#request

i am getting a system stack error when i submit this form:

SystemStackError at /users/11940/request
========================================

> stack level too deep

actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb, line 70
----------------------------------------------------------------------

``` ruby
   65         response = @app.call(env)
   66         response[2] = ActionDispatch::BodyProxy.new(response[2]) { cleanup! }
   67         response
   68       rescue Exception
   69         cleanup!
>  70         raise
   71       end
   72   
   73       def prepare! #:nodoc:
   74         run_callbacks :prepare if validated?
   75       end
```

App backtrace
-------------



Full backtrace
--------------

 - actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:70:in `'

JavaScript to submit via AJAX

     $("#user_feature_request").dialog({
        autoOpen: false,
        width: 500,
        buttons: {
            "Submit": function() {
                var id = $("#request").val();
                $.ajax({
                    url: "/users/" + id + "/request",
                    data: $("#request_form").serialize(),
                    type: "POST",
                    success: function (data) {
                        alert(data);
                        $("#user_feature_request").dialog("close");
                    },
                    error: function (jqXHR, textStatus, errorThrown) {
                        alert('error: ' + textStatus + ': ' + errorThrown);
                    }
                });
                return false;
            },
            "Cancel": function() {
                $(this).dialog("close");
            }
        }
    });
    $("#request").on("click", function() {
        $("#user_feature_request").dialog("open");
    });

Controller

  def request
    user = params[:user]
    r = Request.new
    r.user_id = params[:id]
    r.feature = user[:request]
    r.comment = user[:comment]
    r.repair = user[:issue]
    r.save
  end

Form:

<div class="main">
  <div id="user_feature_request" title="Comment / Requested Features">
    <form id="request_form">
      <input id="user_id" name="user[id]" type="hidden" value="<%= current_user.id %>"></input>
      Requested Feature:
      <textarea cols="450" id="user_request" name="user[request]" rows="5"></textarea>
      <br/>
      Technical Issue:
      <textarea cols="450" id="user_issue" name="user[issue]" rows="5"></textarea>
      <br/>
      Comments:
      <textarea cols="450" id="user_comment" name="user[comment]" rows="5"></textarea>
    </form>
  </div>
</div>

It is due to your model name and/or controller action name ( Request and request ). These are kind of reserved words in Rails.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM