Trying to do the following
@message = render_to_string ( :sender => sender, :template => \"template\" )
But when accessing
It might be the syntax you're using. Try using the :locals argument:
:locals
@m = render_to_string :template => "template", :locals => {:sender => sender}
Then you just need to access sender (without an @) as a local variable inside the template.
sender
@