# Help With partials

**URL:** <https://www.ruby-forum.com/t/help-with-partials/124246>\
**Category:** Rails\
**Created:** [December 27, 2007, 1:54am UTC](https://www.ruby-forum.com/t/help-with-partials/124246 "2007-12-27T01:54:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 1:54am UTC](https://www.ruby-forum.com/t/help-with-partials/124246/1 "2007-12-27T01:54:45Z")

</div>

ok i’m having problems moving a piece of code into a partial

I have a line in a view:

\<%= image\_tag( createturing ) %\>

moving to a partial \_createturing.rhtml and changing the view to:

\<%= render(:partial =\> "createturing") %\>

gives errors:

ActionView::TemplateError (can’t convert nil into String) on line #1  
of accounts/\_createturing.rhtml:  
1: \<%= image\_tag( createturing ) %\>

what changes do i need to make when i move it into the partial?

btw: the function createturing is in a helper if that makes a  
differance!

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 2:26am UTC](https://www.ruby-forum.com/t/help-with-partials/124246/2 "2007-12-27T02:26:56Z")

</div>

On 27 Dec 2007, at 00:54, spokra wrote:

> gives errors:
> 
> ActionView::TemplateError (can’t convert nil into String) on line #1  
> of accounts/\_createturing.rhtml:  
> 1: \<%= image\_tag( createturing ) %\>

By default when looking at the partial createturing rails will set the  
local variable createturing to the value of @createturing which would  
seem to be nil.  
You however don’t want to use the local variable createturing but the  
method of the same name. You can force a method call by saying  
createturing() instead of createturing

Fred

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 2:36am UTC](https://www.ruby-forum.com/t/help-with-partials/124246/3 "2007-12-27T02:36:52Z")

</div>

It’s because you’re trying to pass a local variable to a partial, and  
that  
won’t work. Change it to an instance variable or specify :locals =\> {  
:variable\_name =\> variable\_name } in your partial.

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 2:42am UTC](https://www.ruby-forum.com/t/help-with-partials/124246/4 "2007-12-27T02:42:44Z")

</div>

I knew that it had to be something easy i was missing!! and it works  
correctly now!! Thank you!!

now to implement my refresh of the div…

On Dec 26, 5:26 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 2:30am UTC](https://www.ruby-forum.com/t/help-with-partials/124246/5 "2007-12-27T02:30:39Z")

</div>

spokra wrote:

> ok i’m having problems moving a piece of code into a partial  
> I have a line in a view:  
> \<%= image\_tag( createturing ) %\>  
> moving to a partial \_createturing.rhtml and changing the view to:
> 
> \<%= render(:partial =\> "createturing") %\>
> gives errors: ActionView::TemplateError (can't convert nil into String) on line #1 of accounts/\_createturing.rhtml: 1: \<%= image\_tag( createturing ) %\> what changes do i need to make when i move it into the partial?
> 
> btw: the function createturing is in a helper if that makes a  
> differance!

i think the render line should be:  
\<%= render :partial =\> ‘createturing’ %\> without the brackets~
