One form for different models

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, …


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


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs