Actually the best way to do this is with something like
params[:your_object][:test] = nil if params[:your_object][:test] == @your_object.type
@your_object.update_attributes(params[:your_object])
(simple code: see repeat params[:your_object]→ to be reorganized)
You can also do this in two steps: first extract the type and then update the attributes, but I think this works more.
received_type = params[:your_object].delete(:type)
received_type = nil if received_type == @your_object.type
@your_object.update_attribute :type, received_type
@your_object.update_attributes(params[:your_object])
Hope this helps.
source
share