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

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -