i am using gem dynamic attributes for dynamically creating header and values for one table
additional_fields is a model where i am using dynamic attributes
class AdditionalField < ActiveRecord::Base
has_dynamic_attributes :destroy_dynamic_attribute_for_nil => true
belongs_to :user
end
in additional field table in dynamic_attributes column all the data will be stored in hash like
{"field_blood_group" => "B positive","field_age" => "22"}
while creating if value is blank for any field means it wont get added to table
but the problem is while editing the user and updating if i remove the value for those fields means it is not getting removed from the table and it is saved in database like
{"field_blood_group" => "B positive","field_age" => ""}
instead i want to remove the field having null value and it should be stored as
{"field_blood_group" => "B positive"}
i don’t know how to do this i got struck in this
can any one help me on this
i find a solution for this
before updating the table now i am checking whether the value is blank or not if the value is blank means i am replacing the value by nil and its getting removed from the database
but still i am confused about this working principle bcoz while creating i am not checking whether its value is blank or not
while creating it is not getting created in database if value is null means.after creating if we remove the value means its not removing from database so i am manually giving null for the value now its getting removed
it will be useful
Thank you