From: Adam Shelly Date: 2008-08-09T04:10:26+09:00 Subject: Re: Validating form input On 8/7/08, Rajat Garg wrote: > Hi Everybody, > > I have a simple form whose input I am trying to validate in the controller. > However, this if clause is not getting called at all... Is this a correct > way to do it? > I don't know exactly what's wrong with your statement, but you are missing a || on the end of the first line - so the parser treats the newline like a semicolon, meaning your first two tests are executed but ignored - they have no bearing on the result. In terms of maintainablity/readibility, you may want to reorganize a little. The following code did raise the expected error for me when I set 'params' to your log data: required = { :user=>[:lastname, :email], :fltAvailable=> [:from_airport, :from_time,:mfr_name] } required.each{|key,subset| raise "error" if (params[key].blank? || subset.find{|s| params[key][s].blank?'}) } -Adam