# Undefined method 'each\` for @\<Plan:0xb75eb818\>

**URL:** <https://www.ruby-forum.com/t/undefined-method-each-for-plan-0xb75eb818/115400>\
**Category:** Rails\
**Created:** [September 24, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/undefined-method-each-for-plan-0xb75eb818/115400 "2007-09-24T21:48:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![will](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/90ced4/32.png) [@will](https://www.ruby-forum.com/u/will)\
**Post date:** [September 24, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/undefined-method-each-for-plan-0xb75eb818/115400/1 "2007-09-24T21:48:25Z")

</div>

I am having a problem seaching my Plan object with Plan.find() using  
an array object that appears to be setting itself up incorrectly.  
Here is what I am seeing.

NoMethodError in Generate reportsController#advanced\_plan\_summary

undefined method `each’ for #Plan:0xb7605a24

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/  
active\_record/base.rb:1860:in `method_missing' app/controllers/generate_reports_controller.rb:419:in`advanced\_plan\_summary’

Request

Parameters: {“plans”=\>“3/29”}

How is Ruby setting up my arrays as a string like this instead. Has  
anyone seen this before?

I am using  
Rails 1.2.3  
Ruby 1.8.6  
gems 0.94

---

<div class="post-metadata">

**Author:** ![will](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/90ced4/32.png) [@will](https://www.ruby-forum.com/u/will)\
**Post date:** [September 25, 2007, 10:46am UTC](https://www.ruby-forum.com/t/undefined-method-each-for-plan-0xb75eb818/115400/2 "2007-09-25T10:46:58Z")

</div>

Hi!  
I think that if what you get is x, you are calling x.each() but x is an  
object not an array.

Will wrote:

> I am having a problem seaching my Plan object with Plan.find() using  
> an array object that appears to be setting itself up incorrectly.  
> Here is what I am seeing.
> 
> NoMethodError in Generate reportsController#advanced\_plan\_summary
> 
> undefined method `each’ for #Plan:0xb7605a24

---

<div class="post-metadata">

**Author:** ![will](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/90ced4/32.png) [@will](https://www.ruby-forum.com/u/will)\
**Post date:** [September 25, 2007, 5:52pm UTC](https://www.ruby-forum.com/t/undefined-method-each-for-plan-0xb75eb818/115400/3 "2007-09-25T17:52:00Z")

</div>

I found the problem. You were correct. I kept thinking Ruby was  
misformating the parameter straing. Thinking I should see and array  
in Parameters: {“plans”=\>“3/29”}. This was correct.

@plans = Plan.find(params[:plans])  
My problem was with this code

for plan in @plans  
…  
end

I had to change it to  
for plan in @plans.to\_a  
…  
end

and it worked. Thanks

On Sep 25, 3:46 am, Florencio C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
