Customizing save or moving a method for better design?

Hi you all, I have a “wiki_controller” which gets the page’s title,
summary, and content, stored them in a “Page” model However, I have to
do a kind of parsing in the content to recover annotations made by the
user, and stored them in the “Annotation” model.
I do this with a method located in the “wiki_controller”, which extracts
each annotation and save them one by one.

I wonder if I should move this method to the “annotation_controller”, or
if a should do the parsing when saving the page in the “Page” model, for
what I would have to customize the default save that’s inside Rails for
model (can I?)

What would be the best option for a proper design?.

Thank you

Btw, my question was partially answered here
Design doubt- putting a method in the controller, in model - Rails - Ruby-Forum, but even though I opt for doing
the parsing in the model, I don’t really know if modifying the save
method would be the best idea.
Thanks again.

Damaris F. wrote:

Hi you all, I have a “wiki_controller” which gets the page’s title,
summary, and content, stored them in a “Page” model However, I have to
do a kind of parsing in the content to recover annotations made by the
user, and stored them in the “Annotation” model.

Uh, why? Why not store raw Wiki markup in just one model?


Phlip
Redirecting... ← NOT a blog!!!

Uh, why? Why not store raw Wiki markup in just one model?

Um, I don’t understand you :frowning: I store the content in the Page model, as
an attribute.

The annotations written by the users in the way, let’s say, “blah blah
{{my annotation}} bla bla blah”, are extracted from that same content
and stored in the Annotation model.
The “extract” action is made in the Wiki controller (associated with
Page model). Answers to the other post I made told me it would be better
to set that action in the Annotation model. However, as I do the
extraction after saving the page, I was wondering if I should do the
action in the “save” method of Page model (not Annotation), and if I
could, for that purpose, modify the “save” method of activeRecord by
default in Page model.

Thnaks again :smiley: