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

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:inadvanced_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

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

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. [email protected]

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