Stringify_keys!

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
   [email protected]?
  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

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

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

stringify_keys! destructively converts hash keys to strings.

William P. wrote:

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs