Ruby syntax question, I think

I am successfully navigating between controllers. However, I am unable
to construct a new child (question) record.

What does “undefined method `stringify_keys!’ really mean”?

I think I am missing a subtlety of Ruby syntax here, since the
question_controller is actually trying to call the Question constructor.

Can someone point out what I am missing please?

Thanks in advance.

question_controller:

def new
@question = Question.new(params[:parent_quiz])
end

question.rb:

def new (quiz)
quiz = quiz
end

Application trace:

/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1333:in
attributes=' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1188:ininitialize_without_callbacks’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:236:in
initialize' ./script/../config/../app/controllers/question_controller.rb:20:innew’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1333:in
attributes=' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1188:ininitialize_without_callbacks’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:236:in
initialize' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:inperform_action_without_filters’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in
perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in
perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:inprocess_without_session_management_support’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
process' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:indispatch’
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
handle_dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:inservice’
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
/usr/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
/usr/lib/ruby/1.8/webrick/server.rb:95:in start' /usr/lib/ruby/1.8/webrick/server.rb:92:instart’
/usr/lib/ruby/1.8/webrick/server.rb:23:in start' /usr/lib/ruby/1.8/webrick/server.rb:82:instart’
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
require' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
require' script/server:3 /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1333:inattributes=’
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1188:in
initialize_without_callbacks' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:236:ininitialize’
./script/…/config/…/app/controllers/question_controller.rb:20:in new' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:inperform_action_without_filters’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in
perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr/lib/ruby/1.8/benchmark.rb:293:in measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in
perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:inprocess_without_session_management_support’
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in
process' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:indispatch’
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in
handle_dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:inservice’
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
/usr/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
/usr/lib/ruby/1.8/webrick/server.rb:95:in start' /usr/lib/ruby/1.8/webrick/server.rb:92:instart’
/usr/lib/ruby/1.8/webrick/server.rb:23:in start' /usr/lib/ruby/1.8/webrick/server.rb:82:instart’
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in
dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
require' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require’
script/server:3

2006/3/12, David J. [email protected]:

question.rb:

def new (quiz)
quiz = quiz
end

You never need to define “new” itself, instead you define initialize,
and Ruby calls that for you:

def initialize(quiz)
@quiz = quiz
end

More info here:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/4707

hth,
Douglas

Thanks! I was sure it was something like that.