Forum: Ruby on Rails undefined local variable or method"

C24abd902e125cc84788a513a8efca1b?d=identicon&s=25 Issam Alameh (ialameh)
on 2008-02-17 09:37
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
C24abd902e125cc84788a513a8efca1b?d=identicon&s=25 Issam Alameh (ialameh)
on 2008-02-17 09:43
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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-02-18 12:52
(Received via mailing list)
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
9be62bc981ca5f2363154170981cfe61?d=identicon&s=25 Deepesh Cp (cpdeepesh)
on 2009-08-20 10:22
Frederick Cheung 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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-08-20 10:37
(Received via mailing list)
On Aug 20, 9:22 am, Deepesh Cp <rails-mailing-l...@andreas-s.net>
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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.