I would like to verify a parameter is present before a search is posted.
min_age = params[:min_age]
max_age = params[:max_age]
@users = User.find(:all,
:conditions => ["years >= ? AND years <= ? " min_age,
max_age])
Basically I am just concerned about the max_age.
I tried this:
min_age = params[:min_age]
max_age = params[:max_age]
if max_age.nil?
flash[:notice] = "please enter max age!"
redirect_to :action => "index"
@users = User.find(:all,
:conditions => ["years >= ? AND years <= ? " min_age,
max_age])
But the search still ran with a nil max_age parameter.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.