Для ясности (и семантики) установите эту коллекцию в вашем контроллере для использования в вашем представлении:
@sectors = current_user.company.sectors.order(:sector)
... или если вы хотите ограничить ветви, которые отображаются для каждого сектора пользователем,Возможно, вы захотите собрать коллекцию на основе веток пользователя.Один пример:
@sectors = current_user.company.branches.collect{|b| b.sector}.uniq
Затем, если вы хотите установить значение branch_id И сектор имеет атрибут имени И ветвь имеет атрибут имени, это должно работать:
<%= f.grouped_collection_select(:branch_id, @sectors, :branches, :name, :id, :name, :include_blank=>true)
#:branch_id is the attribute you will be setting on the form_builder's object.
#@sectors is the collection of objects for the groups.
#:branches is the method that will be called on each sector object.
#:name is the method that will be called on each sector object to label the group.
#:id is the method that will be called on each branch to set the option's value.
#:name is the method that will be called on each branch to set the option's label.