Forum: Ruby on Rails checking to see if a variable is set.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jeremy S. (Guest)
on 2005-12-08 22:04
Hey guys, i have a pretty quick question. I need to make an IF statement
that does #action if a certain param (params[:theme]) is set.

How would i go about coding that with ruby? As an example I'll include
the PHP equivilent of what i need to do...

[CODE]<?php
if (isset($_GET['id'])){
# Do some code here, id had a value.
}else{
# Do some code here, id did NOT have a value.
}
?>[/CODE]

OR

[CODE]<?php
if (empty($_GET['id'])){
# Do some code here, id did NOT have a value.
}else{
# Do some code here, id had a value.
}
?>[/CODE]

Thanks,
- Jeremy
ksruby (Guest)
on 2005-12-08 22:30
(Received via mailing list)
if @params[:id]
  # do some code
else
  # do something else
end

Kent.
This topic is locked and can not be replied to.