我知道这里有很多系统堆栈错误问题......但每个问题和答案都是唯一的。并没有找到一个离我很近的地方。
我真的不明白为什么我会收到这个错误...
我不需要视图,因为表单是通过ajax发送的。我验证了我的编码工作,用于使用rails控制台插入新记录。
我验证了路线:
request_user POST /users/:id/request(.:format) users#request
我提交此表单时收到系统堆栈错误:
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 `'
通过AJAX提交的JavaScript
$("#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");
});
控制器
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
形式:
<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>