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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:06:31+00:00 2026-05-20T00:06:31+00:00

I am trying to wrap my head around how to allow a user to

  • 0

I am trying to wrap my head around how to allow a user to create custom forms with all the field types. If there is a gem that would be great, but I cannot seem to find one anywhere.

So I have a DB setup like this which:

  t.integer :form_id
  t.string :name
  t.string :hint
  t.integer :position
  t.string :field_type
  t.boolean :required
  t.integer :size
  t.boolean :multiple
  t.text :values
  t.timestamps

And this is pretty much where I am. I cant think of how to iterate thru the field_type and return the values, as well as associate them with forms actually being filled out.

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-05-20T00:06:31+00:00Added an answer on May 20, 2026 at 12:06 am

    I assume you have some kind of Form model, and then some kind of Field model, and a Form has_many :fields. Correct?

    Building the form is than quite straightforward: retrieve the form, iterate over all the fields, and depending on the type, render the correct code. If you use something like formtastic or simple_form the code is pretty straightforward.

    But to make it work, inside your controller you will have to create a dummy object, that has a getter and setter for all fields. You could use a simple hash for this, or OpenStruct (better). While iterating over the fields set the hash with empty or default values.

    I think you also want to save the results of a form? I think the easiest way is to use a model like this

    t.form_id :integer
    t.fields_data :text
    

    And store the entered data in the text-field in e.g. json or something.
    You could also do something like

    class FormData
      belongs_to :form
    end
    
    class FormDataField
      belongs_to :form_data
      belongs_to :form_field
    end
    

    while this is the cleanest (you can query on values of filled in fields for a certain form), it is maybe too much of an overhead.

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

Sidebar

Related Questions

Trying to wrap my head around django forms and the django way of doing
I'm trying to wrap my head around abstract and explicit self types in scala.
I'm trying to wrap my head around this task and wondering if there is
I'm trying to wrap my head around a Model that allows for multiple checkbox
I'm trying to wrap my head around threading, and I know that I may
I'm trying to wrap my head around querying a table that has hierarchical category
I'm trying to wrap my head around functional programming in ruby and there doesn't
Just trying to wrap my head around how different project types are built and
I'm trying wrap my head around all of the different scripting technologies for Windows
I'm trying to wrap my head around Xcode's file organization - or lack there

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.