# NoMethodError : undefined method \`stringify\_keys!' for "2":String

**URL:** <https://www.ruby-forum.com/t/nomethoderror-undefined-method-stringify-keys-for-2-string/176154>\
**Category:** Rails\
**Created:** [September 25, 2009, 11:59am UTC](https://www.ruby-forum.com/t/nomethoderror-undefined-method-stringify-keys-for-2-string/176154 "2009-09-25T11:59:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/838e76/32.png) [@maddy](https://www.ruby-forum.com/u/maddy)\
**Post date:** [September 25, 2009, 11:59am UTC](https://www.ruby-forum.com/t/nomethoderror-undefined-method-stringify-keys-for-2-string/176154/1 "2009-09-25T11:59:35Z")

</div>

Hi,

I have been trying to create a small Rails application. In one of  
the steps, I am facing this error as “NoMethodError in  
ContactController#update … undefined method `stringify\_keys!’  
for “2”:String”.

Let me give a brief description of the application. This application  
is to Create, View and Update contacts. The problem came when updating  
a record.

The “Update” action in controller file looks like this,

```
   def update
         @contact = Contact.new(params[:id])
         @contact.attributes = params[:contact]
         @contact.save!
         redirect_to :action => "index"
   end

```

Below is the complete error stack,

* * *

xxxxxxxxxxxxxxxx--------------------------------------------------

NoMethodError in ContactController#update  
undefined method `stringify\_keys!’ for “2”:String  
RAILS\_ROOT: D:/rails\_projects/contactlist

Application Trace | Framework Trace | Full Trace  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/  
active\_record/base.rb:2111:in `attributes=' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:1926:in`initialize’  
app/controllers/contact\_controller.rb:24:in `new' app/controllers/contact_controller.rb:24:in`update’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/  
active\_record/base.rb:2111:in `attributes=' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:1926:in`initialize’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/base.rb:1158:in `send' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:1158:in`perform\_action\_without\_filters’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/filters.rb:697:in `call_filters' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:689:in`perform\_action\_without\_benchmark’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/benchmarking.rb:68:in  
`perform_action_without_rescue' D:/RoR/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/benchmarking.rb:68:in  
`perform_action_without_rescue' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/rescue.rb:199:in`perform\_action\_without\_caching’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/caching.rb:678:in `perform_action' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/connection_adapters/abstract/query_cache.rb:33:in`cache’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/  
active\_record/query\_cache.rb:8:in `cache' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/caching.rb:677:in`perform\_action’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/base.rb:524:in `send' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:524:in`process\_without\_filters’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/filters.rb:685:in  
`process_without_session_management_support' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/session_management.rb:123:in`process’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/base.rb:388:in `process' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:171:in`handle\_request’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/dispatcher.rb:115:in `dispatch' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:126:in`dispatch\_cgi’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/dispatcher.rb:9:in `dispatch' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel/rails.rb:76:in`process’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel/rails.rb:74:in `synchronize' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel/rails.rb:74:in`process’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:159:in `process_client' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:158:in`each’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:158:in `process_client' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:285:in`run’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:285:in `initialize' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:285:in`new’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:285:in `run' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:268:in`initialize’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:268:in `new' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:268:in`run’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel/configurator.rb:282:in `run' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel/configurator.rb:281:in`each’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel/configurator.rb:281:in `run' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/ mongrel_rails:128:in`run’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel/command.rb:212:in `run' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/ mongrel_rails:281 D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:489:in`load’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:489:in `load' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:342:in`new\_constants\_in’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:489:in `load' D:/RoR/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/ mongrel.rb:64 D:/RoR/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
D:/RoR/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in`require’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:342:in `new_constants_in' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in`require’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:  
39  
D:/RoR/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' D:/RoR/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/  
active\_record/base.rb:2111:in `attributes=' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/base.rb:1926:in`initialize’  
app/controllers/contact\_controller.rb:24:in `new' app/controllers/contact_controller.rb:24:in`update’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/base.rb:1158:in `send' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:1158:in`perform\_action\_without\_filters’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/filters.rb:697:in `call_filters' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:689:in`perform\_action\_without\_benchmark’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/benchmarking.rb:68:in  
`perform_action_without_rescue' D:/RoR/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/benchmarking.rb:68:in  
`perform_action_without_rescue' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/rescue.rb:199:in`perform\_action\_without\_caching’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/caching.rb:678:in `perform_action' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/connection_adapters/abstract/query_cache.rb:33:in`cache’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/  
active\_record/query\_cache.rb:8:in `cache' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/caching.rb:677:in`perform\_action’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/base.rb:524:in `send' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:524:in`process\_without\_filters’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/filters.rb:685:in  
`process_without_session_management_support' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/session_management.rb:123:in`process’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/base.rb:388:in `process' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:171:in`handle\_request’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/dispatcher.rb:115:in `dispatch' D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:126:in`dispatch\_cgi’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/dispatcher.rb:9:in `dispatch' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel/rails.rb:76:in`process’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel/rails.rb:74:in `synchronize' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel/rails.rb:74:in`process’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:159:in `process_client' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:158:in`each’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:158:in `process_client' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:285:in`run’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:285:in `initialize' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:285:in`new’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:285:in `run' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:268:in`initialize’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel.rb:268:in `new' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel.rb:268:in`run’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel/configurator.rb:282:in `run' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/ mongrel/configurator.rb:281:in`each’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel/configurator.rb:281:in `run' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/ mongrel_rails:128:in`run’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/lib/  
mongrel/command.rb:212:in `run' D:/RoR/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-mswin32/bin/ mongrel_rails:281 D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:489:in`load’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:489:in `load' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:342:in`new\_constants\_in’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:489:in `load' D:/RoR/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/ mongrel.rb:64 D:/RoR/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
D:/RoR/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in`require’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/  
active\_support/dependencies.rb:342:in `new_constants_in' D:/RoR/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in`require’  
D:/RoR/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:  
39  
D:/RoR/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' D:/RoR/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
script/server:3  
Request  
Parameters:

{“commit”=\>“Update”,  
“authenticity\_token”=\>“9ebbca881cc0e31be50530d9b3f1a38fcf1a74d1”,  
“contact”=\>{“city”=\>“bangalo”,  
“country”=\>“India”,  
“phone”=\>“234122342”,  
“first\_name”=\>“abc”,  
“last\_name”=\>“def”,  
“address”=\>“weiwq,  
werwqqq,  
wer”,  
“state”=\>“KA”,  
“email”=\>“removed\_email\_address@domain.invalid”},  
“id”=\>“2”}

Show session dump

* * *

:csrf\_id: 5d52f51ba29b9131292e9e783e78f09b  
flash: !map:ActionController::Flash::FlashHash {}

Response  
Headers:

{“cookie”=\>[],  
“Cache-Control”=\>“no-cache”}

* * *

xxxxxxxxxxxxxxxxxxxxxxx----------------------------------------

What I feel is that there is something wrong with this statement in  
‘Update’ action,

@contact.attributes = params[:contact]

I just don’t have enough command on this language to exactly know the  
problem.

Can anyone help me solving this problem? Please do let me know if any  
additional details are needed.

Many Thanks!!  
Maddy

---

<div class="post-metadata">

**Author:** ![maddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/838e76/32.png) [@maddy](https://www.ruby-forum.com/u/maddy)\
**Post date:** [September 25, 2009, 12:41pm UTC](https://www.ruby-forum.com/t/nomethoderror-undefined-method-stringify-keys-for-2-string/176154/2 "2009-09-25T12:41:53Z")

</div>

maddy wrote:

> 

I think you are updating @contact  
@contact.update\_attributes(params[:contact])

---

<div class="post-metadata">

**Author:** ![maddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/838e76/32.png) [@maddy](https://www.ruby-forum.com/u/maddy)\
**Post date:** [September 25, 2009, 1:01pm UTC](https://www.ruby-forum.com/t/nomethoderror-undefined-method-stringify-keys-for-2-string/176154/3 "2009-09-25T13:01:38Z")

</div>

On Sep 25, 10:57 am, maddy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The “Update” action in controller file looks like this,
> 
> ```
> def update
> @contact = Contact.new(params[:id])
> 
> ```

This should be Contact.find

Fred

---

<div class="post-metadata">

**Author:** ![maddy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/838e76/32.png) [@maddy](https://www.ruby-forum.com/u/maddy)\
**Post date:** [September 29, 2009, 10:32am UTC](https://www.ruby-forum.com/t/nomethoderror-undefined-method-stringify-keys-for-2-string/176154/4 "2009-09-29T10:32:55Z")

</div>

Hi Fred,

Thanks a lot!

You were right. It had to be Contact.find.

Regards,  
maddy
