# Searching with Char like #

**URL:** <https://www.ruby-forum.com/t/searching-with-char-like/196723>\
**Category:** Rails\
**Created:** [June 24, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/searching-with-char-like/196723 "2008-06-24T20:15:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eagoweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@eagoweb](https://www.ruby-forum.com/u/eagoweb)\
**Post date:** [June 24, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/searching-with-char-like/196723/1 "2008-06-24T20:15:17Z")

</div>

Hello i got a field to search a name in the DB

The problem is that the name could have char like #

so in my view:

\<%= text\_field\_with\_auto\_complete :member, :name%\>  
\<%= observe\_field ‘member\_name’,  
:frequency =\> 0.5,  
:update =\> ‘member\_named’,  
:url =\>  
{:controller=\>“admin/members”,:action=\>‘live\_search’},  
:with=\> ‘member\_name’%\>  
so if i put on the textfield “peter #2”  
i got \<%=params[member\_name]%\> peter

so everything after ‘#’ isn’t there, what could i do?

but in the auto\_complete all the names appear while i am writing…

---

<div class="post-metadata">

**Author:** ![eagoweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@eagoweb](https://www.ruby-forum.com/u/eagoweb)\
**Post date:** [June 24, 2008, 10:41pm UTC](https://www.ruby-forum.com/t/searching-with-char-like/196723/2 "2008-06-24T22:41:09Z")

</div>

On Jun 24, 2008, at 11:15 AM, Edgar G. wrote:

> ```
> :url =>
> 
> ```
> 
> {:controller=\>“admin/members”,:action=\>‘live\_search’},  
> :with=\> ‘member\_name’%\>  
> so if i put on the textfield “peter #2”  
> i got \<%=params[member\_name]%\> peter
> 
> so everything after ‘#’ isn’t there, what could i do?

Might be something unique to the Ajax code, or perhaps some filtering  
you’ve forgotten you added. Searching with a plain HTML form, using #  
and other symbol chars is not a problem, params includes those  
characters, etc.

– gw

---

<div class="post-metadata">

**Author:** ![eagoweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@eagoweb](https://www.ruby-forum.com/u/eagoweb)\
**Post date:** [June 25, 2008, 9:45am UTC](https://www.ruby-forum.com/t/searching-with-char-like/196723/3 "2008-06-25T09:45:38Z")

</div>

On Jun 24, 7:15 pm, Edgar G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hello i got a field to search a name in the DB
> 
> The problem is that the name could have char like #

You need to use encodeURIComponent

Fred

---

<div class="post-metadata">

**Author:** ![eagoweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@eagoweb](https://www.ruby-forum.com/u/eagoweb)\
**Post date:** [June 25, 2008, 6:32pm UTC](https://www.ruby-forum.com/t/searching-with-char-like/196723/4 "2008-06-25T18:32:17Z")

</div>

Frederick C. wrote:

> On Jun 24, 7:15ï¿½pm, Edgar G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Hello i got a field to search a name in the DB
> > 
> > The problem is that the name could have char like #
> 
> You need to use encodeURIComponent
> 
> Fred

Could you show me an example using encodeURIComponent

because the char “#” havent get into the param[:member\_name]  
so i am seeking “Peter #23” the \<%=param[:member\_name]%\> show just  
“Peter”

---

<div class="post-metadata">

**Author:** ![eagoweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@eagoweb](https://www.ruby-forum.com/u/eagoweb)\
**Post date:** [June 25, 2008, 6:35pm UTC](https://www.ruby-forum.com/t/searching-with-char-like/196723/5 "2008-06-25T18:35:11Z")

</div>

On 25 Jun 2008, at 08:45, Frederick C. wrote:

> You need to use encodeURIComponent
> 
> > ```
> > :with=> 'member_name'%>
> > 
> > ```

:with =\> “‘member\_name=’ + encodeURIComponent(value)”

Fred

---

<div class="post-metadata">

**Author:** ![eagoweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@eagoweb](https://www.ruby-forum.com/u/eagoweb)\
**Post date:** [June 25, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/searching-with-char-like/196723/6 "2008-06-25T20:08:14Z")

</div>

Hey Fred, thanks man! 😛
