#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    174
    Rep Power
    12

    Swapping key names in a hash


    Hello,

    I'm trying to change the name of a hash key. I want to take a params[:value] and modify some of it's key names to work better in model sql statements.

    for instance I have a param hash key named "title" (params['title']) and I want to change that key name to 'spaces.title' so it will work better w/in a conditional statement in joined table sql call.

    Any ideas?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    174
    Rep Power
    12
    Sweet - found my solution and here it is:

    params[:account]['spaces.title'] = params[:account][:title]
    params[:account].delete(:title)

    Always simpler than I think.

IMN logo majestic logo threadwatch logo seochat tools logo