# Partials and Prototype

**URL:** <https://www.ruby-forum.com/t/partials-and-prototype/90648>\
**Category:** Rails\
**Created:** [March 30, 2007, 5:43pm UTC](https://www.ruby-forum.com/t/partials-and-prototype/90648 "2007-03-30T17:43:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fred](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fred](https://www.ruby-forum.com/u/fred)\
**Post date:** [March 30, 2007, 5:43pm UTC](https://www.ruby-forum.com/t/partials-and-prototype/90648/1 "2007-03-30T17:43:53Z")

</div>

I am having trouble sending a local variable to a partial. When I call  
it from the main program it works, but when I try to do so from a rjs  
file, it wont work.

In my main code I have

\<% for each name in @list %\>  
\<%= render\_partial ‘/printName’, name.id %\>  
\<% end %\>

Then in the \_printName.rhtml file its simply

\<%= "

#{ link\_to\_remote("test", :url =\> {:action =\> "didItWork", :id =\> printName, :update =\> 'name\_#{printName}'} }  

"%\>

Then in the rjs file

if !@name.nil?  
page.replace\_html “name\_#{@name.id}”, render\_partial ‘printName’,  
@name.id  
end

which does not work. Previously I had this working by skipping the  
partial and printing the html code within the rjs file, but that  
violates DRY

if !@name.nil?  
page.replace\_html “name\_#{@name}”,  
"

 #{ link\_to\_remote("test", :url =\> {:action =\> "didItWork", :id =\> @name, :update =\> 'name\_#{@name}'} }   

 " end

Any advice on how to send the variable in the rjs file?
