A user can assign a field due_time_at which has the TIME datatype in the database. After they update with a time they might change there mind and not want a specific time. Currently when the user tries to set the time back to NULL it just sets the field to 00:00 in the DB. Is there any way to get this back to nil?
I was able to get the desired result by forcing "" to all the attributes in the post. I looks like the fields params[:something][:'due_time_at(1i)'], params[:something][:'due_time_at(2i)'], params[:something][:'due_time_at(3i)'] still had data in them even though you set the time to "". If anybody has a better way let me know.
if params[:something][:'due_time_at(4i)'] == ""
params[:something][:'due_time_at(1i)'] = ""
params[:something][:'due_time_at(2i)'] = ""
params[:something][:'due_time_at(3i)'] = ""
params[:something][:'due_time_at(4i)'] = ""
params[:something][:'due_time_at(5i)'] = ""
end
This should work :
If you are passing the params hash to the update_attribute method, you can check its values and set the :due_time_at value to nil.