Forum: Ruby on Rails One form for different models

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Damaris F. (Guest)
on 2007-03-03 15:22
Currently I have a form with some inputs, related to a wiki page. So I
<%= 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, ...

Damaris F. (Guest)
on 2007-03-03 18:51
looking through google I've found this[1], so I will try if it works:

This topic is locked and can not be replied to.