# One form for different models

**URL:** <https://www.ruby-forum.com/t/one-form-for-different-models/87532>\
**Category:** Rails\
**Created:** [March 3, 2007, 2:22pm UTC](https://www.ruby-forum.com/t/one-form-for-different-models/87532 "2007-03-03T14:22:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [March 3, 2007, 2:22pm UTC](https://www.ruby-forum.com/t/one-form-for-different-models/87532/1 "2007-03-03T14:22:10Z")

</div>

Currently I have a form with some inputs, related to a wiki page. So I  
have:  
\<%= text\_field ‘page’, ‘title’ â€¦  
\<%= text\_field ‘page’, ‘summary’ â€¦  
\<%= text\_field ‘page’, ‘body’ â€¦

And a model called “Page”, extending from “ActiveRecord::Base”, and  
storing data in MySQL.

But know I have to record the attributes in some other part, having just  
the “body” att. stored in MySQL, and the other attributes, let’s say, in  
a file.

So, what should I do? I first thought of keeping my “Page \<  
ActiveRecord::Base”, and storing there just the “body” attribute (and  
the table in MySQL just storing this attribute, deleting the other  
columns), and create another model called “Whatever”, which stores the  
other attributes (but not extending from “ActiveRecord::Base”). That way  
my view would have:  
\<%= text\_field ‘whatever’, ‘title’ â€¦  
\<%= text\_field ‘whatever’, ‘summary’ â€¦  
\<%= text\_field ‘page’, ‘body’ â€¦

But, if I did thisâ€¦ how can in my “Whatever” model would validate the  
things I used to validate with a model extending from  
“ActiveRecord::Base”, such as:  
validates\_uniqueness\_of :title…  
validates\_length\_of :title, …  
…

Thanks.

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [March 3, 2007, 5:51pm UTC](https://www.ruby-forum.com/t/one-form-for-different-models/87532/2 "2007-03-03T17:51:30Z")

</div>

looking through google I’ve found this[1], so I will try if it works:

[1] [http://www.railsweenie.com/forums/2/topics/724](http://www.railsweenie.com/forums/2/topics/724)
