Where to factor out a method

Hello All,

A bit of background. I have an EventGroups controller with new/create
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
have EventGroupsBase controller which holds autocomplete_index as both
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.
are no special privileges for Admin over the general public so it
seem right having two routes for it.

Any advice would be great. Thanks


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

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