Rails, same piece of code won't work with 3.2 -


so have on erb:

<%= fields_for camera, :index =>camera.id |field|%> <%= field.check_box :alertflag %> 

and on controller:

 @camera = camera.update(params[:camera].keys, params[:camera].values) 

and works on 1 server have rails 3.0.9, reason doesn't work same way on 1 server have rails 3.2.

the params hash on 3.0.9:

camera%5b10%5d%5balertflag%5d=0 

on 3.2:

camera%5balertflag%5d=0 

so index missing.

the index option supported in both rails versions. when comparing source code of formhelper module in 2 rails versions becomes clear fields_for method signature has changed from:

def fields_for(record_or_name_or_array, *args, &block) 

in rails 3.0, to

def fields_for(record_name, record_object = nil, fields_options = {}, &block) 

in rails 3.2.

so if need pass options (e.g. index), must pass the 3rd argument method now, following should work:

<%= fields_for :camera, camera, :index => camera.id |field| %> 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -