# User defined model and validations?

**URL:** <https://www.ruby-forum.com/t/user-defined-model-and-validations/165967>\
**Category:** Rails\
**Created:** [April 20, 2009, 1:02pm UTC](https://www.ruby-forum.com/t/user-defined-model-and-validations/165967 "2009-04-20T13:02:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsrsrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ed8c4c/32.png) [@rsrsrs](https://www.ruby-forum.com/u/rsrsrs)\
**Post date:** [April 20, 2009, 1:02pm UTC](https://www.ruby-forum.com/t/user-defined-model-and-validations/165967/1 "2009-04-20T13:02:08Z")

</div>

I am trying to wrap my head around an idea and would appreciate any  
input from rails geniuses out there

I would like to allow an admin user to define data that should be in a  
template, and then allow regular users to create instances of this  
template and have it validated. ie:

- Template would have name, files and then x many fields of say “Text  
max length 20 chars”, “Image size 50x50”, “Text 10 chars, not  
required” etc.
- After the template is defined, end user would load it and save  
implementations of that template.

The template would be easy to create say template has\_many  
template\_fields. But how can I load this template, validate it’s data  
and save the instances in another table(s)?

This would be similar to say allowing the admin to define their own  
forms/fields/validations in the database, then saving instances of  
these forms. It seems like this would be a fairly common problem, any  
ideas on this? Is there some type of plugin that might help?

Thanks for any help
