# Stringify\_keys!

**URL:** <https://www.ruby-forum.com/t/stringify-keys/116010>\
**Category:** Rails\
**Created:** [October 1, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/stringify-keys/116010 "2007-10-01T16:49:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [October 1, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/stringify-keys/116010/1 "2007-10-01T16:49:56Z")

</div>

I have seen this numerious times and still have no idea what it means:

undefined method `stringify\_keys!’ for “blah22”:String

I am tring to change a password. My code looks like:

def change\_password  
@user = User.find\_by\_emailaddr( params[:email] )

```
if @user.nil? # user profile not created
  flash[:notice] = "<b style = \"color:red\">No such user email

```

found"  
redirect\_to :action =\> ‘change\_pass’ and return  
end

```
if User.authenticate( params[:email], params[:current_pass] ) and
   !@user.nil?
  if params[:new_pass] == params[:new_passvfy]
    begin
     @user.update_attributes(@user.setpass = params[:new_pass])
    rescue Exception => e
        flash[:notice] = e
        redirect_to :action => 'change_pass'
    else
      redirect_to :action => 'traveler_form' and return
    end
  else
    flash[:notice] = "<b style =\"color:red\">New password fields

```

don’t  
match"  
redirect\_to :action =\> ‘change\_pass’  
end  
else  
flash[:notice] = “\<b style = “color:red”\>Unknown User”  
redirect\_to :action =\> ‘change\_pass’ and return  
end  
end

Once upon a time this all worked. Then I made some changes in another  
part of the controller to get something else working on another page,  
but odviously this two parts are related somehome, but I don’t see how.  
Where is the ‘stringify\_keys!’ coming from and what does it mean? Thanks  
in advance,

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [October 1, 2007, 5:43pm UTC](https://www.ruby-forum.com/t/stringify-keys/116010/2 "2007-10-01T17:43:48Z")

</div>

stringify\_keys! destructively converts has keys to strings. You are  
getting this error because you are passing a string to a function that  
is expecting a hash.  
[http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/Hash/Keys.html](http://api.rubyonrails.com/classes/ActiveSupport/CoreExtensions/Hash/Keys.html)

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [October 1, 2007, 5:46pm UTC](https://www.ruby-forum.com/t/stringify-keys/116010/3 "2007-10-01T17:46:08Z")

</div>

Sorry for the typo, still haven’t had my first cup of coffee 🙂

stringify\_keys! destructively converts hash keys to strings.

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [October 1, 2007, 6:21pm UTC](https://www.ruby-forum.com/t/stringify-keys/116010/4 "2007-10-01T18:21:47Z")

</div>

William P. wrote:

> Sorry for the typo, still haven’t had my first cup of coffee 🙂
> 
> stringify\_keys! destructively converts hash keys to strings.

Thanks. That makes perfect sense. Im my user model I was using  
‘update\_attributes’ and then passing in one of my param arguments  
instead of the entire set of parameters. Once I changed that everything  
worked, Thanks again,

–Shandy
