Forum: Ruby on Rails Can you use a mixin to add action methods to an ActionContro

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
88f7e16d7e0629a0589df6ff9563c67b?d=identicon&s=25 pacred (Guest)
on 2007-05-21 23:00
(Received via mailing list)
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-a...
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
This topic is locked and can not be replied to.