Frederick Cheung wrote in post #988609:
> What error?
Sorry, now that I reread my post, it's not very clear.
I am getting the error "can't add a new key into hash during iteration"
reported for this line of code:
params[:search_form] ||= {}
which makes no sense at all. The iteration examples in my first post
were just my way of explaining I understood the basic error msg and what
it would normally relate to. However, the actual error msg is not
tracing back to an iteration--just that simple line with params ||=.
Experimenting a little more, it appears it matters _where_ I use that
line of code.
I'm not sure how to distill this down, so here's the semi-detailed
version...
Two relevant files: a rails controller, and a module file stored in /lib
which gets included in ApplicationController.
#---------------------------------------
class MyController < ApplicationController
include GwControllerExtras
def admin
sasc_initialize(...) # an abstraction for handling a bunch of UI
interaction
end
private
# called from within sasc_initialize()
def submit_form_x
end
# called from within sasc_initialize()
def prep_view_y
update_sticky_search
end
end
#---------------------------------------
# /lib/admin_ui_extras.rb
module GwControllerExtras
def update_sticky_search
params[:search_form] ||= {} # <<<<< FAILS
# more stuff
end
end
OK, so the line that fails is the one shown just above. Now, if I move
that line out of the update_sticky_search method and into the
prep_view_y method just before the call to update_sticky_search, there
is no error. Bizarre!
There's a couple other places where I can move it in the call chain that
either crashes or doesn't crash with the "can't add a new key into hash
during iteration" error. So, somehow, location matters.
There's something specific to 192 here, because update_sticky_search
works fine in 186 and 187.
I hope that's clearer.
-- gw
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.