Problem manipulating params for login

Taylor Strait wrote:

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 Smith." The database
contains first_name and last_name columns. In the console when I
substitute "Bob Smith" 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]])

Use:

name_array = params[:person][:login_name].split(/ /)

>> params[:person][:login_name]
=> "John Smith"

>> 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 Smith"]