Forum: Ruby on Rails Validation

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.
Cory W. (Guest)
on 2006-03-29 08:54
Gang,

Let's say I have a search form that takes two pieces of search criteria:
for the purposes of this discussion, let's use 'zip' and 'radius'.  Is
there a rails idiom for validating that user-provided input meets some
conditions before moving forward with a particular action?  For
instance, I want to ensure that the user has provided me with a non-null
zip and a non-null radius that falls within a given range.

As best I can tell - this doesn't really fall into proper Model
validation because this is just form input for a particular search.
Surely there's a more elegant way to handle this outside of:

if params[:zip].nil?
  flash[:foo] = "please provide a zip"
  redirect_to...
end

Any suggestions?
This topic is locked and can not be replied to.