Marius Pop
Marius Pop

Reputation: 1461

rails, select_tag, options_for_select - connecting select_tag to form_for

I have a form_for(@task) do |f| . Each task belongs to a group. I have a select_tag(:group_id, options_for_select(@groups). @groups returns the array with the options.

After some googling I can't seem to find the way to say f.select_for instead of just select_tag so that I can actually connect it to my model.

Can anybody point me in the right direction?

Upvotes: 0

Views: 1948

Answers (1)

dennis
dennis

Reputation: 2020

First of all I do not really understand what you are trying to do so here is my assumption:

You want to make a form select feature wich holds the related group.id value.

f.select :group_id, options_for_select(@group.map(&:id), default_value)

Upvotes: 2

Related Questions