Undefined local variable or method"

Hello,

I am trying to render a partial with a collection

<%= render :partial => ‘classified’, :collection => @classifieds %>

this one works

but if I changed my partial name to list for example

<%= render :partial => ‘list’, :collection => @classifieds %> and
changed the name of my partial to _list.html.erb

I get the error

undefined local variable or method `classified’ for
#ActionView::Base:0x4a55bf0

does the name of the partial must match the name of the variable
classified?

What is the way around that

Can someone help please

I figured out it is a naming convention issue, I have renamed variables
in my partial to list instead of classified (as per the partial name)
and it worked

but is there any way around that

Issam

On 17 Feb 2008, at 08:43, Issam Alameh wrote:

I figured out it is a naming convention issue, I have renamed
variables
in my partial to list instead of classified (as per the partial name)
and it worked

but is there any way around that
Nope, that’s pretty much the way partials work - you get a local
variable with the same name as the partial

Fred

Frederick C. wrote:

On 17 Feb 2008, at 08:43, Issam Alameh wrote:

I figured out it is a naming convention issue, I have renamed
variables
in my partial to list instead of classified (as per the partial name)
and it worked

but is there any way around that
Nope, that’s pretty much the way partials work - you get a local
variable with the same name as the partial

Fred

i tried to run hello.rb which contains puts “HAI DEEPESH”

ruby hello.rb but i am getting
NameError: undefined local variable or method `hello’ for main:Object
from (irb):6

On Aug 20, 9:22 am, Deepesh Cp [email protected]
wrote:

i tried to run hello.rb which contains puts “HAI DEEPESH”>>ruby hello.rb but i am getting

NameError: undefined local variable or method `hello’ for main:Object
from (irb):6

Sounds like you’re trying to do this from an irb console. Why not do
it from the command prompt ? (if you do want to shell out and execute
something from irb you should have a look at `` or system)

Fred

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