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.
7d3d749be49d37da773bc66dc8a548ed?d=identicon&s=25 Jeremy Sarda (jeremysarda)
on 2005-12-08 21: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
3ccecc71b9fb0a3d7f00a0bef6f0a63a?d=identicon&s=25 ksruby (Guest)
on 2005-12-08 21: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.