I have a View that can vary significantly, depending on the 'mode' a particular user has chosen.
I thought I would extract the different behavior into two different Helpers, and then have code like this in the Controller:
class MyController < ApplicationController
case mode
when 'mode1'
helper "mode1"
when 'mode2'
helper "mode2"
else
raise "Invalid mode"
end
etc...
Once the correct helper is loaded, then a statement like <%= edit_item %> , which is defined in both helpers, will load the correct form for the particular 'mode'.
This works beautifully in development, but in production, the case statement is only run once. Then you are stuck with whatever helper was first loaded (Duh! I should have known that.)
I have thought of other ways to achieve what I need to do, but I still think this use of Helpers is a nice clean way to change behavior of a View.
Does anyone know how I can load (or reload) a helper at runtime?
TIA: John