Question

I'm making a business administration Rails app.

Is there any info available on how I can enable admin users to add a new field to a table? Behind the scenes this would generate and run the migration and I guess some metaprogramming to include the field in the index, show and _form.html.rb views..

Was it helpful?

Solution

You can't run migrations like that, but you can solve the problem.

The answer is here

403-dynamic-forms

If you con't have a subscription, get one. Railscasts is gold for any rails developer

Basically you make a table in the database for the fields to a model.

For instance

class Product
 has_many :product_fields
end   
class ProductFields 
 belongs_to :product
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top