Ruby-on-Rails update_attributes strong pramaters rails 4
I'm attempting to follow
http://railscasts.com/episodes/165-edit-multiple-revised for updating
multiple records simultaneously. However I need to make some changes to
accommodate rails 4.
The controller:
def update_multiple
@products = Product.find(params[:product_ids])
@products.reject! do |product|
product.update_attributes(params[:product].reject { |k,v| v.blank? })
end
end
def product_params
params.require(:product).permit(:id, :x, :y, :z)
end
This throws an error on the update_attributes I understabd rails 4
requires strong paramaters so I have tried:
product.update_attributes(product_params.reject { |k,v| v.blank? })
and
product.update_attributes(product_params[:product].reject { |k,v| v.blank? })
again both throw errors.
No comments:
Post a Comment