已更新...
我的ajax表格提交有问题。不确定它是否是路由问题,或者可能是UJS问题。 (使用jquery 1.6.1和最新的jquery-ujs)
这是为创建操作表单生成的html
<form method="post" id="new_product_pressing" data-remote="true" class="simple_form product_pressing" action="/products/my_product_id/product_pressings" accept-charset="UTF-8">
<input type="hidden" value="✓" name="utf8">
<input type="hidden" value="blablablatokenblablabla" name="authenticity_token">
<label for="product_pressing_total_pressed">Total pressed</label>
<input type="text" size="5" required="required" name="product_pressing[total_pressed]" id="product_pressing_total_pressed"
<input type="submit" value="Create Pressing" name="commit" id="product_pressing_submit">
</form>
更新操作表单也是有效的,但发布时可能是多余的
我的路线是:
resources :products, :shallow => true do
resources :product_pressings, :as => :pressings, :only => [:create, :update]
end
product_pressings POST /products/:product_id/product_pressings(.:format) {:action=>"create", :controller=>"product_pressings"}
pressing PUT /product_pressings/:id(.:format) {:action=>"update", :controller=>"product_pressings"}
用于创建操作...日志显示:
Started POST "/products/product-057/product_pressings" for 127.0.0.1 at...
Processing by ProductPressingsController#create as JS
Parameters: {"product_id"=>"my_product_id"}
如果我删除了远程true,则会传递"product_pressing"=>{}
个参数,但不会传递:remote =&gt;真。
更新......
Started POST "/product_pressings/4e01ad24e1607cc46100008e" for 127.0.0.1 at...
ActionController::RoutingError (No route matches "/product_pressings/4e01ad24e1607cc46100008e"):
抛出路由错误,即使它显示的确切网址和方法为没有远程=&gt;真正。这是有效的,我不确定什么时候停止,但我不明白什么可能导致这种行为。
答案 0 :(得分:0)