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!!

3
  • You'd probably want some noSQL type database where the schema is dynamic. Try mongo (From the FAQs) Commented Apr 4, 2013 at 18:33
  • If you're on Postgres you could also use their hstore column type and serialize custom fields into that. blog.artlogic.com/2012/09/13/custom-fields-in-rails Commented Apr 4, 2013 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? Commented Apr 4, 2013 at 19:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.