← Back to Upcase

Dynamic sql tables based on user input and requirement

(charlieanna) #1

How can I create an sql table dynamically based on user input. For example, a user wanting to create a table on my database where he could then store his information. Just like providing developers a way to use my database to store their data instead of themselves creating a new rails app and deploying.

(Gergely Molnar) #2

I did something similar in the past. I used NoSQL not SQL because it is a better fit for this I think(no need for migrations etc). First I gave a try to Module::const_missing but it didn’t work well unfortunately. I was getting segfaults when I created some test data with relations. So I ended up with custom generators. When a user created an model in the tool I am calling a generator which generates the actual model file based on the properties.