Rails 3 two selects with the same options but keep values unique -
i trying figure out how deal 2 select boxes same options (i using formtastic gem) , force unique values. example:
<select name="departure" size="1"> <option value="1">ny</option> <option value="2">fl</option> <option value="3">la</option> </select> <select name="arrival" size="1"> <option value="1">ny</option> <option value="2">fl</option> <option value="3">la</option> </select>
the simplest way use jquery, know if there validation option in rails 3 handle such scenario. in advance!
you'll have write own think.
validate :departure_cant_equal_arrival def departure_cant_equal_arrival if departure.present? , arrival.present? , (departure == arrival) errors.add(:arrival, "can't same departure") end end
Comments
Post a Comment