Hi
I have the following code:
@lunchtimes = Lunchtime.find_by_dayname("#{todayname}")
for l in @lunchtimes do
# i = lunch.lunchfrom
# j = lunch.lunchto
# while i < j do
# id="#{session[:dateviewing]}/#{i.strftime(’%H:%M:00’)}/#
{lunch.therapist_id}"
# page[id].replace “
# end
# i += 15.minutes
end
I’ve put the hashes in to see where the code is failing BTW!
All I’m trying to do is loop through the search results from
@lunchtimes. At the moment the query is returning only one record:
=> #<Lunchtime id: 4, therapist_id: 1, dayname: “Thursday”, lunchfrom:
“2000-01-01 12:00:00”, lunchto: “2000-01-01 13:00:00”, effective:
“2009-06-04”, created_at: nil, updated_at: nil>
And, as such I’m getting the following error:
NoMethodError (undefined method each' for #<Lunchtime:0x21c1c70>): /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/ attribute_methods.rb:260:in
method_missing’
/app/controllers/appointment_controller.rb:178:in
`__instance_exec0’
With more than one returned search results it works …
I know it’s probably something simple … but can anyone tell me where
I’m going wrong. I’m sure similar code is working in other parts of my
program.
Thanks in advance for your help.
Darren