Instance variables in helpers?

Hi,

Can someone tell me why the following isn’t setting an
instance variable? Perhaps they can’t be set/used in helpers? I have a
revision_info method in ApplicationHelper that returns the current SVN
revision number (used for debugging info in the footer):

module ApplicationHelper
def revision_info
logger.info(“In revision_info(); rev=#{@rev}”) # @rev is always nil
if (@rev ||= (capistrano_revision_info || svn_revision_info)).blank?

  return nil
else
  return 'Revision ' + @rev
end

end
end

capistrano_revision_info returns the revision number from the REVISION file

capistrano_revision_info returns the revision number from svn info --xml

Thanks in advance for any replies.

Cheers,
Lee

At least I can tell you that it *is* possible to set instance
variables in helper methods *and* get them when calling the same
helper later on, so the problem must be somewhere else in the code.
Did you try going to the console and check what the two methods
#capistrano_revision_info and #svn_revision_info actually returns?
Maybe that's the problem, I don't know, but it's definitely not the
instance variables.

But you can only use the member variables from the class(es) which include the module.

James.

maybe i misunderstand, but what i see is a helper-method in
application_helper. i don't know how many times you call that method
in one single view, but if you call it only once @rev is not yet set
when you write it into your log file.

does the method return your revision-number correctly?

if so, why don't you just write something like this:

  Footer ... <%= revision_info %>