# Undefined method \`name' for "41":String

**URL:** <https://www.ruby-forum.com/t/undefined-method-name-for-41-string/185447>\
**Category:** Rails\
**Created:** [March 20, 2010, 9:11am UTC](https://www.ruby-forum.com/t/undefined-method-name-for-41-string/185447 "2010-03-20T09:11:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shyam\_mohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@shyam\_mohan](https://www.ruby-forum.com/u/shyam_mohan)\
**Post date:** [March 20, 2010, 9:11am UTC](https://www.ruby-forum.com/t/undefined-method-name-for-41-string/185447/1 "2010-03-20T09:11:02Z")

</div>

plz see this  
[http://pastie.org/878267](http://pastie.org/878267)  
reply if u find any error or suggestion…  
plz its urgent

Regards,  
Shyam  
+91-9716-18-9650

---

<div class="post-metadata">

**Author:** ![shyam\_mohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@shyam\_mohan](https://www.ruby-forum.com/u/shyam_mohan)\
**Post date:** [March 20, 2010, 9:39am UTC](https://www.ruby-forum.com/t/undefined-method-name-for-41-string/185447/2 "2010-03-20T09:39:08Z")

</div>

On Sat, Mar 20, 2010 at 1:09 AM, shyam mohan  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> 

Shyam, local variables are not accessing within the view. Thus, you’ll  
need  
to change

charges = Charge.find(:all,:conditions =\>“company\_id =#{comp\_id}”)

to

@charges = Charge.find(:all,:conditions =\> [ “company\_id = ?” , comp\_id  
] )

Next, I would recommend reading “Agile Web D. with Rails 3rd”  
as well

as the [guides.rubyonrails.org](http://guides.rubyonrails.org).

Good luck,

-Conrad

–

---

<div class="post-metadata">

**Author:** ![shyam\_mohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@shyam\_mohan](https://www.ruby-forum.com/u/shyam_mohan)\
**Post date:** [March 20, 2010, 11:03am UTC](https://www.ruby-forum.com/t/undefined-method-name-for-41-string/185447/3 "2010-03-20T11:03:24Z")

</div>

Hi

Conrad

Thanks for replying  
but problem was some thing else…  
thanks

Regards,  
Shyam  
+91-9716-18-9650

---

<div class="post-metadata">

**Author:** ![shyam\_mohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@shyam\_mohan](https://www.ruby-forum.com/u/shyam_mohan)\
**Post date:** [March 20, 2010, 11:11am UTC](https://www.ruby-forum.com/t/undefined-method-name-for-41-string/185447/4 "2010-03-20T11:11:36Z")

</div>

On Sat, Mar 20, 2010 at 3:01 AM, shyam mohan  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Shyam  
> +91-9716-18-9650

Did you resolve the issue?

-Conrad

---

<div class="post-metadata">

**Author:** ![shyam\_mohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@shyam\_mohan](https://www.ruby-forum.com/u/shyam_mohan)\
**Post date:** [March 20, 2010, 1:57pm UTC](https://www.ruby-forum.com/t/undefined-method-name-for-41-string/185447/5 "2010-03-20T13:57:52Z")

</div>

On 20 March 2010 10:08, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You have
> 
> \<%=h charge.name %\>
> 
> Where is the variable called charge setup?

I think in the cherry-picking of code to put into pastie, an “each”  
line was missed out around here:  
\<% charges = params[:charges]  
if charges %\>  
\<%=h charge.name %\>

But the upshot is; if you are populating “charges” from the params  
hash, what is in params? I’d put money on params[:charges] returning  
an array of integers that are ids of charges (hence getting “undefined  
method `name’ for “41”:String” as the error). If you want “charges” to  
be a collection of Charge objects that match the ids in  
params[:charges] - get that all sorted in the controller.

---

<div class="post-metadata">

**Author:** ![shyam\_mohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@shyam\_mohan](https://www.ruby-forum.com/u/shyam_mohan)\
**Post date:** [March 20, 2010, 11:11am UTC](https://www.ruby-forum.com/t/undefined-method-name-for-41-string/185447/6 "2010-03-20T11:11:00Z")

</div>

On 20 March 2010 08:09, shyam mohan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> plz see this  
> [http://pastie.org/878267](http://pastie.org/878267)  
> reply if u find any error or suggestion…  
> plz its urgent

You have

\<%=h charge.name %\>

Where is the variable called charge setup?

You might like to have a look at rails guide on debugging, it will  
show you several ways of analysing this sort of issue when you cannot  
see the problem by code inspection. [http://guides.rubyonrails.org/](http://guides.rubyonrails.org/)  
Look particularly at the use of ruby-debug.

Colin
