This is what I see in the developer log
[code=]Processing ProductsController#display_variant_parameters (for
127.0.0.1 at 2009-03-18 17:50:25) [POST]
Session ID: 33b195edc7a6946365ae55efe5e349dd
Parameters:
{"authenticity_token"=>"bc18fccde1f10c5f100e78adbbac88c2f6c535b3",
"product"=>{"product_category_id"=>"7"},
"action"=>"display_variant_parameters",
"controller"=>"products"}
[4;36;1mUser Columns (0.008000) [0m [0;1mSHOW FIELDS FROM
`users` [0m
[4;35;1mUser Load (0.006000) [0m [0mSELECT * FROM `users` WHERE
(`users`.`id` = 1) LIMIT 1 [0m
7
Rendered products/_product_variant_parameter (0.00400)
Rendered products/_product_variant_parameter (0.00000)
Rendered products/_product_variant_parameter (0.00100)
Rendered products/_product_variant_parameter (0.00100)
Completed in 0.04100 (24 reqs/sec) | Rendering: 0.00900 (21%) | DB:
0.01400 (34%) | 200 OK [http://localhost/products/
display_variant_parameters][/code]
Why is the _product_variant_parameter partials getting rendered 4
times ?
My controller code is as follows. For simplicity sake, I have replaced
the original business logic with a hardcoded hash. The behavior is the
same.
[code=]def display_variant_parameters
# Parameters:
{"authenticity_token"=>"9c0dc9b28f19a5b746cfa17e6450d61eacdca816",
"product"=>{"product_category_id"=>"6"},
"action"=>"display_variant_parameters",
"controller"=>"products"}
logger.info params[:product][:product_category_id]
@variants_params_hash = {1 => "password0",
"adi" => "password1",
"aaron" => "password2" }
@variants_params_hash.merge({"sam1" => "password3"})
@variants_params_hash.merge!({"sam2" => "password3"})
render :partial => "product_variant_parameter", :collection =>
@variants_params_hash
end[/code]
The same is invoked on change of the select box
[code=] <% @product_categories = ProductCategory.find(:all,
:order =>
"title" )
f.collection_select(:product_category_id,
@product_categories, :id, :title , {:prompt => true},
{:onchange =>remote_function(:update =>
"product_variants_div",
:url => { :action => :display_variant_parameters},
:with => ''Form.Element.serialize(this)'')
} )
%>[/code]
The controller is not invoked multiple times. It is only the rendering
of the partials, as per the development log. This is just driving me
crazy for the last 3 days
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---