Fair enough point about modules but...

I have 3 controllers that pretty much displayed the same data.  The
differences are in initial filter status, whether edit controls are
displayed, and privileges for different user groups.  As I worked, I
was making the same changes 3 times to the shared code for displaying
(filtering, sorting) the records.  So, I refactored and put all the
the query and formatting code in a class defined in a module.  The
controllers just set the values of class attributes to change the
behavior.

The three controllers are:
    index:  read only display of all records with sort/filter controls
    edit:  depending on the user's group, the user gets bounced, or
can only edit own records, or can edit anyone's records--displays edit
buttons (edit / delete)
    moderate:  depending on the user's group, the user gets bounced,
or can update the status of records, or can edit any record--displays
edit buttons and adds a filter for status

Is there a better way to factor code shared by several controllers
than a class in a module?

On Feb 22, 5:56 am, pbreit <[email protected]> wrote:
> The track_changes should work fine. It's hard to tell if you need all th 
> selfs without seeing mor code. I'm not sure what you are trying to do but I 
> would rarely suggest doing that in a module. You'll save a lot of brain cells 
> avoiding modules.

Reply via email to