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”

Any suggestions?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs