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

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -