Validations is not working when I use select tag in rails
if i remove the validations everything works fine .
but if i keep validations
following error happens
undefined method `map' for nil:NilClass
Extracted source (around line #10):
<div class="field">
<%= f.label :Vehicle_Number %><br />
<%= f.select "vehicle_id",
options_from_collection_for_select(@vehicledevice,"vehicle_id","vehicle_number"),
:prompt => "No vehicle"%>
</div>
please solve the problem
error is at f.select “vehicle_id” complete line
The error is you have @vehicledevice declared in your new action and when you submit the form it takes you to the create action which in turns give you the validations error. Just call the same @vehicledevice in your create action in the else block of your respond_to and the problem will be solved.