D
D
Denis Lysenko2014-05-14 10:55:12
MySQL
Denis Lysenko, 2014-05-14 10:55:12

How to store models with dynamic fieldset in Rails?

There was a need to store a different set of fields in the database for different users, for example, there is an "Order" entity, for one user it will have only two fields - name and phone number, for another - a dozen fields. Moreover, the user himself should be able to select the fields that he needs (that is, we cannot create 20 fields in advance and for some users simply do not fill in unnecessary ones). What is the best way to store things like this in a Rails 4.1 application so that this functionality doesn't become a performance bottleneck? Perhaps you should use something other than MySQL (default database)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
rsludge, 2014-05-14
@rsludge

1. You can use document-oriented databases, such as Mongo
2. You can use Postgres and the hstore extension.

B
Boris Penkovsky, 2014-06-18
@Able1991

I made custom fields via a separate model and a
has_many :fields, through relationship:

V
Viktor Vsk, 2014-07-14
@viktorvsk

And if the information about the order is json, which is stored in one field? When rendering, a form is built. When adding - an input is added

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question