# Problem with params and a string

**URL:** <https://www.ruby-forum.com/t/problem-with-params-and-a-string/105635>\
**Category:** Rails\
**Created:** [May 31, 2007, 10:02pm UTC](https://www.ruby-forum.com/t/problem-with-params-and-a-string/105635 "2007-05-31T22:02:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![turnkeytraders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ba8739/32.png) [@turnkeytraders](https://www.ruby-forum.com/u/turnkeytraders)\
**Post date:** [May 31, 2007, 10:02pm UTC](https://www.ruby-forum.com/t/problem-with-params-and-a-string/105635/1 "2007-05-31T22:02:13Z")

</div>

def index  
cond = params[:letter] + “%”  
@clients = Client.find :all, :conditions =\> [“firstname like ?” ,  
cond], :order =\> “firstname ASC”  
end

This is my code and it gives me an error everytime saying this:

You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occurred while evaluating nil.+

How can I fix this?

Thanks

---

<div class="post-metadata">

**Author:** ![turnkeytraders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ba8739/32.png) [@turnkeytraders](https://www.ruby-forum.com/u/turnkeytraders)\
**Post date:** [May 31, 2007, 10:22pm UTC](https://www.ruby-forum.com/t/problem-with-params-and-a-string/105635/2 "2007-05-31T22:22:10Z")

</div>

> The error occurred while evaluating nil.+
> 
> How can I fix this?

What is the value of params[:letter] ? If it’s nil you need to check  
for  
that…

if params[:letter].nil? # or possibly .blank?

# throw a hissy fit

return  
end

---

<div class="post-metadata">

**Author:** ![turnkeytraders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ba8739/32.png) [@turnkeytraders](https://www.ruby-forum.com/u/turnkeytraders)\
**Post date:** [May 31, 2007, 11:35pm UTC](https://www.ruby-forum.com/t/problem-with-params-and-a-string/105635/3 "2007-05-31T23:35:36Z")

</div>

Philip H. wrote:

> > The error occurred while evaluating nil.+
> > 
> > How can I fix this?
> 
> What is the value of params[:letter] ? If it’s nil you need to check  
> for  
> that…
> 
> if params[:letter].nil? # or possibly .blank?
> 
> # throw a hissy fit
> 
> return  
> end

Oh i see! thats what my problem was, thanks!
