This is probably some dumb mistake on my part, but I’m not seeing it.
I have a simple app that I’m playing with. In this scenario I have a
meeting that I want to add agenda items to. When I click the submit
button in this form I get a “stringify keys” error.
I’d appreciate it if someone could point out my error. What
tools/practices do you use to trouble shoot these kinds of problems?
the error =======================================================
(enter “New Agenda Item” in the text box)
the error =======================================================
NoMethodError in MeetingsController#addagendaitem
undefined method `stringify_keys!’ for “New Agenda Item”:String
RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1506:in
attributes=' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1354:in
initialize_without_callbacks’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/callbacks.rb:236:in
initialize' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/has_many_association.rb:14:in
new’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/has_many_association.rb:14:in
build' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/association_collection.rb:88:in
create’
#{RAILS_ROOT}/app/controllers/meetings_controller.rb:23:in
addagendaitem' -e:4:in
load’
-e:4
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1506:in
attributes=' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1354:in
initialize_without_callbacks’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/callbacks.rb:236:in
initialize' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/has_many_association.rb:14:in
new’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/has_many_association.rb:14:in
build' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/association_collection.rb:88:in
create’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
send' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
perform_action_without_filters’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in
perform_action_without_benchmark' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue’
C:/ruby/lib/ruby/1.8/benchmark.rb:293:in measure' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in
perform_action' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
send’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
process_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in
process_without_session_management_support’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in
process' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in
dispatch’
C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in
handle_dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in
service’
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in
run’
C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in start_thread' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in
start’
C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start_thread' C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in
start’
C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in each' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in
start’
C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in start' C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in
start’
C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require’
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require’
C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require’
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
script/server:3
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1506:in
attributes=' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1354:in
initialize_without_callbacks’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/callbacks.rb:236:in
initialize' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/has_many_association.rb:14:in
new’
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/has_many_association.rb:14:in
build' C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations/association_collection.rb:88:in
create’
#{RAILS_ROOT}/app/controllers/meetings_controller.rb:23:in
addagendaitem' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
send’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
perform_action_without_filters' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in
perform_action_without_benchmark’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' C:/ruby/lib/ruby/1.8/benchmark.rb:293:in
measure’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in
perform_action’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
send' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
process_without_filters’
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in
process_without_session_management_support' C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in
process’
C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in
dispatch' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in
handle_dispatch’
C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in
service' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in
service’
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run' C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in
start_thread’
C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in
start_thread’
C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in start' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in
each’
C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in start' C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in
start’
C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in start' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
dispatch’
C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require’
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' C:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require’
C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
require' C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require’
script/server:3
-e:4:in `load’
-e:4
Request
Parameters: {“name”=>“New Agenda Item”, “commit”=>“Add agenda item”,
“id”=>“1”}
Show session dump
:user: 1
:return_to:
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}
from meetings_controller.rb =========================================
…
def addagendaitem
Meeting.find(params[:id]).agenda_items.create(params[:name])
end
…
show.rhtml in views/meetings ========================================
Run a Meeting
<%= render :partial => “run_meeting” %>
Agenda Items
<% for agenda_item in @meeting.agenda_items %> <%= agenda_item.name %> <% end %><%= form_tag :action => “addagendaitem”, :id => @meeting %>
Agenda Item:
<%= text_field_tag “name” %>
<p>
<%= submit_tag 'Add agenda item' %>
</p>
<%= end_form_tag %>