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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:58:16+00:00 2026-06-02T00:58:16+00:00

Is there any gem/plugin for ruby on rails which gives the ability to define

  • 0

Is there any gem/plugin for ruby on rails which gives the ability to define custom fields in a model at runtime with no need to change the model itself for every different field.

I’m looking for something like Redmine acts_as_customizable plugin which is packaged as a gem usable in the rails way, i.e.

gem 'gemname'
rails g something
rails db:migrate

class Model < ActiveRecord::Base
  acts_as_something
end

Here are the CustomField and the CustomValue classes used in Redmine.

Edit:

Since my question is not clear I add a brief use case which explains my need better:

I want users to be able to design their own forms, and collect data
submitted on those forms. An important decision is the design of how
these custom dynamic records are stored and accessed.

Taken from here, in this article approach the problem with different ideas, but they all have drawbacks. For this reason I’m asking if the issue has been approached in some gem with no need to rethink the whole problem.

  • 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-02T00:58:17+00:00Added an answer on June 2, 2026 at 12:58 am

    I’m afraid it could be tricky and complicated to do it in ActiveRecoand (generally in standard relational database). Take a look at http://mongoid.org/docs/documents/dynamic.html – this mechanism is using nosql feature.

    You can also may try the following trick:

    1/ Serialize a hash with your custom fields in the database column, for example { :foo => 'bar', :fiz => 'biz' }

    2/ After load a record from database do some metaprogramming and define corresponding methods on the record’s singleton class, for instance (assume that custom fields are stored and serialized in custom_fields column):

    after_initialize :define_custom_methods
    # ..or other the most convinient callback
    
    def define_custom_methods
      # this trick will open record's singleton class
      singleton_class = (class << self; self; end)
      # iterate through custom values and define dynamic methods
      custom_fields.each_with_key do |key, value|
        singleton_class.send(:define_method, key) do
          value
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any ruby gem/ rails plugin available for parsing the resume and importing
I want to convert rails plugin into gem. Is there any way to make
Is there any gem or plugin which can be used to send push alerts
Is there any gem which works on Rails 3 that can show which part
Is there any open source (or example) code for Ruby on Rails which can
Is there any gem or plugin for uploading videos in rails application? can anybody
Is there any gem which adds # encoding: UTF-8 to each Ruby file automatically?
Is there any tool to convert plugin to gem and vice versa.
I am creating a Rails plugin (yes, I need a plugin, not a gem).
Is there any solution to work with Btrieve/Pervasive db from Ruby level? Any gem?

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.