On Thu, Mar 01, 2007 at 01:48:32PM -0600, Bill W. wrote:
create a new hash element with the new name and then delete the old one
though.
It is possible to change an existing key; that’s why Hash#rehash exists.
That said, I just tried to actually accomplish it with string keys and
couldn’t manage it. It does work with arrays, however:
irb> x = { [1,2] => 3, [4,5] => 6 }
=> {[1, 2]=>3, [4, 5]=>6}
irb> x.keys
=> [[1, 2], [4, 5]]
irb> x.keys.first << 99
=> [1, 2, 99]
irb> x.keys
=> [[1, 2, 99], [4, 5]]
irb> x[[1,2]]
=> nil
irb> x[[1,2,99]]
=> nil
irb> x.rehash
=> {[4, 5]=>6, [1, 2, 99]=>3}
irb> x[[1,2,99]]
=> 3
params[:title].delete
This has syntax problems. Try this:
params[:“spaces.title”] = params.delete(: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.
Best regards,
Bill
–Greg