undefined method `name' for "41":String

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

Regards, Shyam +91-9716-18-9650

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

Regards, Shyam +91-9716-18-9650

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 Development with Rails 3rd" as well
as the [guides.rubyonrails.org](http://guides.rubyonrails.org).
Good luck,
-Conrad
 
Conrad

Hi Thanks for replying but problem was some thing else… thanks

Regards, Shyam +91-9716-18-9650

You have <td><%=h charge.name %></td>

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/ Look particularly at the use of ruby-debug.

Colin

Conrad

Hi Thanks for replying but problem was some thing else… thanks

Regards, Shyam +91-9716-18-9650

Did you resolve the issue?

-Conrad

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 %>     <td><%=h charge.name %></td>

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.