"locals" in render partial

Hi all,

I’m getting an error and I really don’t know why, because I seem to be
doing everything well…I pass “testvar” as a variable to render partial:

<%= render(:partial => “main/categorysmallitem”, :collection =>
group_of_four, :locals => {:testvar=>“AA”})%>

But then, when I try to use testvar inside the partial, it doesn’t
recognize it:

<%= testvar %>

I get the error:
undefined local variable or method `testvar’ for
#<#Class:0xb743eff4:0xb743efcc>

Thanks a lot
Victor

I’m having the same problem! render :partial isn’t working as
advertised in this case.

Would anybody have ideas? This is driving me nuts.

I’ll try the latest rails gem to see if that helps… I’ll post again if
so… arrrrghh…
– Dan

I just tried v1.1.6, and no dice – I’m not seeing local variables in
my partial templates.

HELP!

I am running a newer revision of edge and I am having this same problem.

wait, nope…it does work. Looks like its fixed in the later edge, I
am running 5196.

The problem in my case was purely ‘inattentiveness’: my partial was not
called by
the code passing the locals.
I would try to debug your code flow to see if you really are calling the
partial from where you think you are.

good luck
Victor

Dan C. wrote:

I just tried v1.1.6, and no dice – I’m not seeing local variables in
my partial templates.

HELP!

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