Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8853103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:34:01+00:00 2026-06-14T13:34:01+00:00

i am using gem dynamic attributes for dynamically creating header and values for one

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:34:02+00:00Added an answer on June 14, 2026 at 1:34 pm

    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

    params[:additional_field] = {"field_blood_group" => "B positive","field_age" => ""}
    
    for field in params[:additional_field]
     field[1] = field[1].blank? ? nil : field[1]
     @user.additonal_field.update_attribute(field[0],field[1])
    end
    

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the rmagick gem for generating dynamic images from a controller. The
I using devise gem for registration but i have problem. my table include: first_name,
I have STI model #a/m/document.rb class Document < ActiveRecord::Base end #a/m/document/static.rb class Document::Static <
I've been working to pull dynamic data from last.fm using youpy's lastfm gem. Getting
Using gem 'bootstrap-generators', '~> 2.0' gem 'simple_form', '~> 2.0' Bootstrap style is non-existant in
I'm using gem ckeditor, 3.7.1 in my rais project. When I'm trying to upload
When I download something using gem I'd like to be able to just download
I'm using gem bundler (v.0.9.6) and Rails 2.3.5, rubygems 1.3.6 and ruby 1.8.7 (On
Whenever I try installing anything using gem, I get this error - murtaza@murtaza-dev:~$ sudo
I recently installed a ruby based tooling using gem, and when I try to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.