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 8743583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:42:17+00:00 2026-06-13T11:42:17+00:00

Forgive me if this has been answered, I have spent a while going through

  • 0

Forgive me if this has been answered, I have spent a while going through similar questions but none of them appear to achieve what I’m looking for.

I have a model named Contact which stores information for a.. contact. I would like to add the ability to add custom fields. That is, a user can store a key and value which is stored in a serialized object on the model. Because the key is custom I can’t just use attr writers to access the values as if they were on the model itself.

I have tried serializing this as a Hash but my problem is using form inputs for when submitting the data. For this reason I started using an Array of Hashes with [{key: ‘foo’, value: ‘bar’}] but again, when editing the form the old values wont show up and I’m not entirely sure of the best way to approach this. I was trying to achieve this with fields_for :extra_values

  • 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-13T11:42:18+00:00Added an answer on June 13, 2026 at 11:42 am

    There are some small problems with storing data in serialized fields in model. First, ActiveRecord always consider serialized fields dirty, as a result, the record in database will always be updated whenever save is called. Second, it is difficult to search the data saved in serialized fields. So I suggest adding another model ExtraValue to store those values, and making Contact has_many :extra_values. Then you can take advantage of nested forms to build your form.

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

Sidebar

Related Questions

Forgive me if this has been answered. I spent a few hours searching for
I've looked for similar questions, but this must have been asked before. Either way,
forgive me if this has been covered, but I promise to have searched beforehand.
First, forgive me if this has been answered already. I spent a few hours
Forgive me if this has been asked before. I have poured through this site
Forgive me if this has been asked before, but I assure you I've scoured
Forgive me if this has been asked before, I am sure it has but
Forgive me if this question has been asked before but I am new to
Forgive me if this question has already been asked, but... I'm trying to select
I am aware that this question has been asked before, but I have tried

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.