Where to factor out a method

Hello All,

A bit of background. I have an EventGroups controller with new/create
which
are available to the general public and the rest of the CRUD actions are
available to the Admin::EventGroups controller. Because of the split, I
also
have EventGroupsBase controller which holds autocomplete_index as both
new
and edit use it.

EventGroupsBaseController < ApplicationController
def autocomplete_index

EventGroupsController < EventGroupsBaseController
def new/create

Admin::EventGroupsController < EventGroupsBaseController
def index/show/edit/update/destroy

No problem. But in my JQuery, I now have a condition in my autocomplete,
testing if it’s a new form or an edit form. A new form calls
/event_groups/autocomplete_index and the edit form calls
/admin/event_groups/autocomplete. Ugly!!

So I was wondering where is the best place to put that common method.
There
are no special privileges for Admin over the general public so it
doesn’t
seem right having two routes for it.

Any advice would be great. Thanks

-ants

I think I’ll answer my own question. I’ll use a mixin.

Ignore all of these mails. It’s late, I should’ve stopped working 4
hours
ago.

I really wasn’t thinking straight. It’s all sorted now.