# Problem manipulating params for login

**URL:** <https://www.ruby-forum.com/t/problem-manipulating-params-for-login/88493>\
**Category:** Rails\
**Created:** [March 12, 2007, 2:11am UTC](https://www.ruby-forum.com/t/problem-manipulating-params-for-login/88493 "2007-03-12T02:11:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [March 12, 2007, 2:11am UTC](https://www.ruby-forum.com/t/problem-manipulating-params-for-login/88493/1 "2007-03-12T02:11:48Z")

</div>

I can get this to work in the console by subbing a string for  
params[:person][:login\_name] but my application won’t “catch” and  
convert the params in the development site. Here is the login function:

```
  #find user record by unique name
  name_array = %w{params[:person][:login_name]}
  name_array.each {|name| name.gsub!(/\"/, "")}
  @person = Person.find(:first,
                        :conditions => ["first_name = ? and

```

last\_name = ?", name\_array[0], name\_array[1]])

People log in with their full name like, “Bob S…” The database  
contains first\_name and last\_name columns. In the console when I  
substitute “Bob S.” for params[:person][:login\_name] the record is  
retrieved normally. But it doesn’t work with params. Any suggestions?

This variation doesn’t work either:

```
  #find user record by unique email
  name = params[:person][:login_name]
  name_array = []
  name_array = %w{name}
  name_array.each {|name| name.gsub!(/\"/, "")}
  @person = Person.find(:first,
                        :conditions => ["first_name = ? and

```

last\_name = ?", name\_array[0], name\_array[1]])

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [March 12, 2007, 2:26am UTC](https://www.ruby-forum.com/t/problem-manipulating-params-for-login/88493/2 "2007-03-12T02:26:23Z")

</div>

Taylor S. wrote:

> last\_name = ?", name\_array[0], name\_array[1]])  
> #find user record by unique email  
> name = params[:person][:login\_name]  
> name\_array = []  
> name\_array = %w{name}  
> name\_array.each {|name| name.gsub!(/"/, “”)}  
> @person = Person.find(:first,  
> :conditions =\> [“first\_name = ? and  
> last\_name = ?”, name\_array[0], name\_array[1]])

Use:

name\_array = params[:person][:login\_name].split(/ /)

> > params[:person][:login\_name]  
> > =\> “John S.”

> > name\_array = params[:person][:login\_name].split(/ /)  
> > =\> [“John”, “Smith”]

With %w, no substitutions are done on the inputs – i.e. they are  
assumed to  
be literal string values. With %W substitutions can be done but they  
aren’t  
split afterwards.

> > name\_array = %w{params[:person][:login\_name]}  
> > =\> [“params[:person][:login\_name]”]

> > name\_array = %w{#{params[:person][:login\_name]}}  
> > =\> ["#{params[:person][:login\_name]}"]

> > name\_array = %W{params[:person][:login\_name]}  
> > =\> [“params[:person][:login\_name]”]

> > name\_array = %W{#{params[:person][:login\_name]}}  
> > =\> [“John S.”]

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [March 12, 2007, 2:50am UTC](https://www.ruby-forum.com/t/problem-manipulating-params-for-login/88493/3 "2007-03-12T02:50:52Z")

</div>

Thanks Michael that worked perfectly!
