# Hash names with white spaces

**URL:** <https://www.ruby-forum.com/t/hash-names-with-white-spaces/159078>\
**Category:** Rails\
**Created:** [January 31, 2009, 8:57am UTC](https://www.ruby-forum.com/t/hash-names-with-white-spaces/159078 "2009-01-31T08:57:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [January 31, 2009, 8:57am UTC](https://www.ruby-forum.com/t/hash-names-with-white-spaces/159078/1 "2009-01-31T08:57:50Z")

</div>

Hi all,

I’ve got a simple problem and I am wondering if it can be solved.  
In my code I use Hash params name including white spaces (coming from  
legacy database). They works well in my View, but I am not able to  
properly use them later in my controller.  
For instance, in my view I have:

It works, and checking params confirms that person[first name] it’s also  
posted, but I don’t know how to use it in controller. If I try:

print params[:person][:first name]

I always receive errors regarding [:first name] ; so seems that Hash  
names including white spaces are not accepted…

Any suggestion will be appreciated.

Thanks in advance

Stefano

---

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [January 31, 2009, 9:47am UTC](https://www.ruby-forum.com/t/hash-names-with-white-spaces/159078/2 "2009-01-31T09:47:02Z")

</div>

Hi Stefano,

First of all, migrate your database. Legacy dbs suck and there’s no  
reasons  
why to preserve them for too long.

About your problem:  
Both params[‘first name’] and params[:‘first name’] will work.

ciao, tom

–  
Thomas R. “TomK32” Koll \<\> [http://ananasblau.com](http://ananasblau.com)  
just a geek trying to change the world  
[TomK32 (Thomas R. Koll) · GitHub](http://github.com/TomK32)

---

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [January 31, 2009, 12:42pm UTC](https://www.ruby-forum.com/t/hash-names-with-white-spaces/159078/3 "2009-01-31T12:42:34Z")

</div>

Hi Tom,

first of all many thanks for your suggestion.

I cannot migrate from the legacy database because it is still populated  
by an electronic PLC wich has only MS ACCESS (aargh!) or MS SQL  
connectors.  
The same for DB field names.  
They where defined five years ago and so I must live with them.

Anyway, I will try your hint about quotes usage asap and then post the  
result here.

Ciao & have a nice day

Stefano

---

<div class="post-metadata">

**Author:** ![mex23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47774/32.png) [@mex23](https://www.ruby-forum.com/u/mex23)\
**Post date:** [January 31, 2009, 1:12pm UTC](https://www.ruby-forum.com/t/hash-names-with-white-spaces/159078/4 "2009-01-31T13:12:32Z")

</div>

Ok Tom,

like you suggested, both params[‘first name’] and params[:‘first name’]  
worked for me.

Case solved.

Thanks again

Stefano
