UPDATED...
i am having trouble with my ajax form submissions. not sure if its a routing issue, or possibly a UJS issue. (using jquery 1.6.1 and the most recent jquery-ujs)
this is the generated html for the create action form
<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>
the update action form is valid as well, but probably redundant to post
my routes are:
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"}
for the create action... the log shows:
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"}
if i remove remote true, the "product_pressing"=>{}
parameters get passed, but not with :remote => true.
for update...
Started POST开发者_Python百科 "/product_pressings/4e01ad24e1607cc46100008e" for 127.0.0.1 at...
ActionController::RoutingError (No route matches "/product_pressings/4e01ad24e1607cc46100008e"):
throws a routing error, even though its shows the exact url and method as without remote => true. this was working, and im not sure when it stopped, but i don't understand what could cause this behavior.
found the problem. my fault. i had extended jquery with plugins named $.param and $.params. that was conflicting with jquery ujs apparently. it wasn't easy to track down, but just had to rename it. problem solved.
精彩评论