Help With partials

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!

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

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.
http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.

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. [email protected]

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~

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs