Can you use a mixin to add action methods to an ActionContro

I am trying to use a module to define a common interface between several
ActiveRecord model classes, but I am having trouble setting the instance
variable in the mixin functions. For example, I have a function,
def showusername
@user = …
If I put this function in the action controller, it works fine, but if I
move it to the module, the instance variable @user is nil when I try to
it in the .rhtml file. Does anyone know why this is? Did I just
the code incorrectly or am I using mixins incorrectly

I briefly read that you can only use mixins to define non-action
Does anyone know if this is true and why that would be the case?

Anyway, I would greatly appreciate any advice. I found examples of
using mixins to add methods to Active Record classes, but none of these
functions tried to set instance variables or acted as action methods, so
feel I am incorrectly using the mixin.


View this message in context:
Sent from the RubyOnRails Users mailing list archive at