ruby on rails - Simple Form collection, but exclude a specific record -
here code use generate select list of companies.
<%= f.association :company, :collection => company.order('name asc'), :label => "company: ", :include_blank => false %>
now table pre-populated special record "id:1, name:none", want exclude record selectable option in select list that's generated. how can go accomplishing this?
thanks!
try
<%= f.association :company, :collection => company.where("id != 1").order('name asc'), :label => "company: ", :include_blank => false %>
or
in controller @companies = company.where("id != 1").order('name asc') in view <%= f.association :company, :collection => @companies, :label => "company: ", :include_blank => false %>
Comments
Post a Comment