|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
Sweet - found my solution and here it is:
params[:account]['spaces.title'] = params[:account][:title] params[:account].delete(:title) Always simpler than I think. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Ruby Programming > Swapping key names in a hash |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|