I have a select form in Rails and currently I am using a list for the form in my view and Profile model:
class Profile < ActiveRecord::Base
validates :country, inclusion: { :in => CITYLIST }
CITYLIST = %w[LA NYC Miami Boston]
end
In my view,
<%= f.select(:city, Profile::CITYLIST, {:include_blank => "Select"}, {:class => "editstyle"}) %>
Currently, the user has to select a value from the city list before his profile is saved. What I'd like is that the user need not select a value from the list. As in he can save his profile by leaving the value blank, but if he chooses to select a value, only then the value must be validated from the list.