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!!
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!!
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
[email protected]
Thank you! I got it. Thanks for the suggestion, I will definitely do
that.