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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:56:03+00:00 2026-06-06T10:56:03+00:00

I have a User and Setting . Setting has a :serializable field called :custom_links

  • 0

I have a User and Setting. Setting has a :serializable field called :custom_links:

In Setting.rb

  serialize :custom_links, Hash

In User.rb

has_one :setting, dependent: :destroy

I’d like to create a form that allows users to set any number of custom links, and store those in the :custom_links hash. Each custom link has a Name and a URL in the hash.

I’m not sure how to structure this form in the view and allow users to dynamically add as many custom links as they want using javascript (and save those in the :custom_links hash). I have other fields in :setting and I have my controller working fine with those fields – I think the only thing I need help with is the view and javascript.

UPDATE for clarification:

When a user completes the form to enter :custom_links, I’d like it to be in the following format:

{
:name => "Google", :url => "http://www.google.com",
:name => "Twitter", :url => "http://www.twitter.com"
}

Also, I’d like to be able to dynamically add 2 text fields for each :custom_link that the user wants to enter.

Any and all help is appreciated.

Thanks

  • 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-06T10:56:06+00:00Added an answer on June 6, 2026 at 10:56 am

    I would suggest adding those links as a separate model (eg. has_many :custom_links). As an extra, you’ll be able to use AR’s validations instead of making your own custom validation methods for the serialized attribute.

    You can use nested attributes for these fields. Take at look at the following railscasts episodes:

    • http://railscasts.com/episodes/196-nested-model-form-part-1
    • http://railscasts.com/episodes/197-nested-model-form-part-2

    The second one also shows you how to dynamically add more fields with javascript.

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

Sidebar

Related Questions

I have a relationship like this class User include Mongoid::Document include Mongoid::Timestamps embeds_one :setting
I have a has_one association between user and setting model. I have also SettingsController
I have a problem: change setting in user control's configuration file has no effect.
I have two models with a one-to-one association. class User < ActiveRecord::Base has_one :setting
I have contenteditable span with a max-width setting that allows the user to enter
I'm setting up a group / user based security system. I have 4 tables
I have a boolean setting in my Properties/Settings.settings file, which basically stores per user
okay, i'm setting up a multi-user chat system. i have a messages table, that
I have a Boolean, user scoped setting. I access it through a referenced class
i have an usercontrol that has a public event. when i use this user

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.