# Simple Link\_to Question

**URL:** <https://www.ruby-forum.com/t/simple-link-to-question/129075>\
**Category:** Rails\
**Created:** [February 14, 2008, 12:32am UTC](https://www.ruby-forum.com/t/simple-link-to-question/129075 "2008-02-14T00:32:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [February 14, 2008, 12:32am UTC](https://www.ruby-forum.com/t/simple-link-to-question/129075/1 "2008-02-14T00:32:18Z")

</div>

Hello,  
I’m still really new to Ruby on Rails and I just need some  
clarification… So if I define a param in a link\_to in my view like so:

\<%= link\_to match[‘name’], :controller =\> ‘compare’, :action =\>  
‘viewinfo’, :param1 =\> match[‘name’], :param2 =\> match[‘number’] %\>

How do I call param1 and param2 once in the controller? I’m trying to do  
something like this:

if param1 != nil && param2 != nil

However, just saying ‘param1’ and ‘param2’ doesn’t work because it is an  
undefined local variable… How can I use them as such?

Thank you!!

- Jeff

---

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [February 14, 2008, 12:44am UTC](https://www.ruby-forum.com/t/simple-link-to-question/129075/2 "2008-02-14T00:44:05Z")

</div>

On Feb 13, 2008, at 6:32 PM, Jeff M. wrote:

> something like this:
> 
> if param1 != nil && param2 != nil
> 
> However, just saying ‘param1’ and ‘param2’ doesn’t work because it  
> is an  
> undefined local variable… How can I use them as such?
> 
> Thank you!!
> 
> - Jeff

Try:  
if params[:param1] && params[:param2]

no need to add the ‘!= nil’ since only nil and false are not “true”.

If you’re that new, you need to spend a bit of time learning Ruby  
itself since all your code will be ruby code written with Rails  
conventions.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![sithadmin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@sithadmin](https://www.ruby-forum.com/u/sithadmin)\
**Post date:** [February 14, 2008, 1:31am UTC](https://www.ruby-forum.com/t/simple-link-to-question/129075/3 "2008-02-14T01:31:53Z")

</div>

Thank you! I got it. Thanks for the suggestion, I will definitely do  
that.
