Sometimes instead of specific db fields, you want to store custom field on database that is changing according to user needs in same app.
I coded following method to store this type of dynamic data. As you see in codes, it uses metaprogramming methods.
Also, there is simple validation to custom field that is number.
There is simple rails app that is using this type of custom field method. You can access source code below link:
If you want to demo, there you go: https://rails-custom-field-ransack.herokuapp.com