Williams, Chris
12/3/2004 5:52:00 PM
Hi all,
I'm developing a rails web app here at work and I keep running into
a common thing in terms of setting instance variables with the property of a
form's parameter value. Basically I want the variable to take the
parameter's value if it exists, and to otherwise use a reasonable default.
I keep writing code like this:
if @params["limit"]
@limit = @params["limit"]
else
@limit = 50
end
if @params["chain"]
chain = @params["chain"]
else
chain = 1
end
Can someone please point me to a simpler, more succinct "ruby" way of doing
this?
Thanks,
Chris