Answer the question
In order to leave comments, you need to log in
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
1. You can use document-oriented databases, such as Mongo
2. You can use Postgres and the hstore extension.
I made custom fields via a separate model and a
has_many :fields, through relationship:
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 questionAsk a Question
731 491 924 answers to any question