0

I'm looking at the best way to manage a dynamic models in rails from a web interface; for example lets say i have a product model and from the admin web interface I want to be able to add a new field/column with the related data type (e.g. a new field "description" of type string). I've though of two possible ways:

  1. Create migration file from the web interface:

    rails generate migration table field:type

    rake db:migrate

  2. Implement the definition of the model in the database itself.

This last solution seems like reinventing the wheel and more cumbersome to maintain but I couldn't come up with a better solution, what would you recommend?

I've came across this solution although my concern is too keep things simple and standard.

Any suggestions would be great, thanks!!

Community
  • 1
  • 1
  • You'd probably want some noSQL type database where the schema is dynamic. Try [mongo](http://docs.mongodb.org/manual/faq/fundamentals/#do-mongodb-databases-have-schemas) (From the FAQs) – spullen Apr 04 '13 at 18:33
  • If you're on Postgres you could also use their hstore column type and serialize custom fields into that. http://blog.artlogic.com/2012/09/13/custom-fields-in-rails/ – jstim Apr 04 '13 at 18:45
  • im actually using mysql and i will look into the implications of switching to mongodb. So what you are telling me is that the first solution would not work or have disadvantages? – AlexanderKocisky Apr 04 '13 at 19:47

0 Answers0