# Check what is comming in param

**URL:** <https://www.ruby-forum.com/t/check-what-is-comming-in-param/174411>\
**Category:** Rails\
**Created:** [August 26, 2009, 3:37pm UTC](https://www.ruby-forum.com/t/check-what-is-comming-in-param/174411 "2009-08-26T15:37:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![karthik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9fc348/32.png) [@karthik](https://www.ruby-forum.com/u/karthik)\
**Post date:** [August 26, 2009, 3:37pm UTC](https://www.ruby-forum.com/t/check-what-is-comming-in-param/174411/1 "2009-08-26T15:37:24Z")

</div>

hi guys

i am checking with params[:a].nil? and params[:a].blank?

but in the url a is not coming but for some other purpose service i am  
using  
the same a for some other service

if some params is nit coming in url how to check

guide me

–  
Karthik.k  
Mobile - +91-9894991640

---

<div class="post-metadata">

**Author:** ![karthik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9fc348/32.png) [@karthik](https://www.ruby-forum.com/u/karthik)\
**Post date:** [August 26, 2009, 3:53pm UTC](https://www.ruby-forum.com/t/check-what-is-comming-in-param/174411/2 "2009-08-26T15:53:53Z")

</div>

Karthik Kantharaj wrote:

> hi guys
> 
> i am checking with params[:a].nil? and params[:a].blank?
> 
> but in the url a is not coming but for some other purpose service i am  
> using  
> the same a for some other service
> 
> if some params is nit coming in url how to check
> 
> guide me
> 
> –  
> Karthik.k  
> Mobile - +91-9894991640

One purpose, one name.  
Once your code is free from ambiguity, it’ll be easier to help you.

---

<div class="post-metadata">

**Author:** ![karthik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9fc348/32.png) [@karthik](https://www.ruby-forum.com/u/karthik)\
**Post date:** [August 26, 2009, 4:49pm UTC](https://www.ruby-forum.com/t/check-what-is-comming-in-param/174411/3 "2009-08-26T16:49:24Z")

</div>

2009/8/26 karthik k [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> hi guys
> 
> i am checking with params[:a].nil? and params[:a].blank?
> 
> but in the url a is not coming but for some other purpose service i am using  
> the same a for some other service
> 
> if some params is nit coming in url how to check

I don’t understand the question. If a is not in the url then  
params[:a] will be nil as you say. Please explain more in what way  
this does not work for you.

Colin

---

<div class="post-metadata">

**Author:** ![karthik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9fc348/32.png) [@karthik](https://www.ruby-forum.com/u/karthik)\
**Post date:** [August 26, 2009, 5:01pm UTC](https://www.ruby-forum.com/t/check-what-is-comming-in-param/174411/4 "2009-08-26T17:01:13Z")

</div>

Colin L. wrote:

> I don’t understand the question. If a is not in the url then  
> params[:a] will be nil as you say. Please explain more in what way  
> this does not work for you.
> 
> Colin

“I am checking with params[:VARNAME].nil? and params[:VARNAME].blank?.  
My problem is that I use a variable VARNAME for some other purpose as  
well. How can I tell?”

I mean, you COULD check the format of the VARNAME, but if it’s two  
similar hashes, you’re out of luck anyway. Best to rename one of them so  
there’s no ambiguity, and then the problem goes away.

---

<div class="post-metadata">

**Author:** ![karthik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9fc348/32.png) [@karthik](https://www.ruby-forum.com/u/karthik)\
**Post date:** [August 26, 2009, 8:29pm UTC](https://www.ruby-forum.com/t/check-what-is-comming-in-param/174411/5 "2009-08-26T20:29:06Z")

</div>

2009/8/26 Aldric G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> well. How can I tell?"  
> It does not matter if you have a variable called varname (don’t use  
> VARNAME, upper case implies a constant in ruby). params[:varname]  
> checks whether the params hash contains an entry for the key varname  
> and is not affected by any variable called varname.

---

<div class="post-metadata">

**Author:** ![karthik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9fc348/32.png) [@karthik](https://www.ruby-forum.com/u/karthik)\
**Post date:** [August 26, 2009, 8:36pm UTC](https://www.ruby-forum.com/t/check-what-is-comming-in-param/174411/6 "2009-08-26T20:36:51Z")

</div>

Colin L. wrote:

> It does not matter if you have a variable called varname (don’t use  
> VARNAME, upper case implies a constant in ruby). params[:varname]  
> checks whether the params hash contains an entry for the key varname  
> and is not affected by any variable called varname.

Okay, sorry. I was worried about being english-readable and I became  
ruby-unreadable.

I -think- he is saying that he has:  
params[:varname] … And params[:varname] may exist for some other  
purpose but not the purpose he needs, so he wants to make sure it’s the  
params[:varname] he wants. Does that make sense?  
Yeah, it doesn’t make sense to me either. That’s why I suggested only  
passing parameters with unique names.
