XML into database

Hi,

I like to save www-forms into one text-field in database by using XML.

Example:

Bill Gates ....

And not to make 100*n fields into table.

Is there any easy way for this? Add/Edit/Show data…?

I like to save www-forms into one text-field in database by using XML.

And not to make 100*n fields into table.

Hi,

you could define the virtual (=not mapped to db fields) attributes in
your model through attr_accessor. Then you could use the after_find
and before_save callbacks to write the contents of these attributes as
XML into your single text field, as well as deserialize them back into
the virtual attributes when a model object is loaded from database.

Jan

On 20 Apr 2008, at 13:04, Gi Ga wrote:


And not to make 100*n fields into table.

You do realize that is really quite limiting? For example you cannot
efficiently pick the first 10 users ordered by last name, select those
users with property x and so on. You will also have to provide
accessors for all the attributes, although I imagine it would not be
hard to generate those at run time (similar to what ActiveRecord does).

Fred

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