Select input element using f.select() of items connected by a linking table (in Rails) -


I have an example of "project"; Each project has several clients, each client has a unique pair organization and person Person).

Therefore, there are many relationships with the client in the project. There are many relationships with the organization with many relationships and organization.

See an image of the model diagram:

The project, I want to be able to change the organization for every client through the select menu drop down, but I can select the input items The organizations are having problems in appearing.

What do I do here:

  & lt;% form_for (@project) do | F | & Gt%; & Lt;% @ project.clients.each do | Customer | & Gt%; & Lt;% = f.select ("client.organization_id", disclosure.Collect {| D | [D. color.titlecase, d.id]})% & gt; & Lt;% end% & gt; & Lt;% end% & gt;  

I know this is wrong, but I do not know how to get a select drop-down menu that I want, with a company affiliated with each customer. The selection menu is the default selection

Any help?

Your schema makes me feel weird ... but by no means ..

If you want to list all organizations in the selection and want to default now, try this:

    

Client.Correction_ID that should be selected currently if it is a comfortable editing action docs:

with the example @ post.person_id => 1: < / P>

  ("post", "person_id", Person.all.collect {| p | [p.name, p.id]}, {: include_blank => true} )  

can be:

  & lt; Select name = "post [person_id]" & gt; & Lt; Option value = "" & gt; & Lt; / Options & gt; & Lt; Option value = "1" selected = "selected" & gt; David & lt; / Option & gt; & Lt; Option value = "2" & gt; Sam & lt; / Options & gt; & Lt; Option value = "3" & gt; Tobias & lt; / Option & gt; & Lt; / Select & gt;  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -