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


#1

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 = …
end
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
call
it in the .rhtml file. Does anyone know why this is? Did I just
implement
the code incorrectly or am I using mixins incorrectly

I briefly read that you can only use mixins to define non-action
methods.
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
people
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
I
feel I am incorrectly using the mixin.

Thanks,
Chris


View this message in context:
http://www.nabble.com/Can-you-use-a-mixin-to-add-action-methods-to-an-ActionController--tf3756642.html#a10617591
Sent from the RubyOnRails Users mailing list archive at Nabble.com.