Clem Rock wrote:
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.
I don't think you can change the name of an existing key. It's easy to create a new hash element with the new name and then delete the old one though.
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.
I'm not 100% sure that Rails will let this work in the controller since the params hash is constructed by the browser and read in the controller. Having said that, and assuming the key names you want to use are valid for Ruby hashes...
params[:spaces.title] = params[:title]
If that doesn't work then you'll probably have to construct a new hash, copy the params hash into it, and then modify it to suit your needs. There's probably a 'slicker' way to do it too. Maybe someone else will chime in with one.