Hello pullmonkey.
YOu insight was helpful. I check the html code of my setup and realised that my method and values were incorrect. I finally did this in my view:
<p>
<%= f.label :company %><br />
<%= f.collection_select ( :company, Client.find(:all), :firstname, :firstname ) %>
</p>
My HTML code looks like this:
<p>
<label for="ticket_company">Company</label><br />
<select id="ticket_company" name="ticket[company]">
<option value="Redro">Redro</option>
<option value="Cortnie">Cortnie</option>
<option value="Zethan">Zethan</option>
<option value="Jack">Jack</option>
<option value="Jade">Jade</option>
<option value="Reggie">Reggie</option>
<option value="Nicola">Nicola</option></select>
</p>
(I know, I am using firstname for a company name, but I am still learning and will perfect it once I got the just of things.)
It goes something like this if explained:
<%= object.collection_select ( :method, collection, :value_method, :text_method ) %>
Basically I wanted to pull a list of contacts from a client list and throw it into another form as a drop down list so one could choose. The value and method are relevant to the database and field its pulling from, company is the field it will use to post to in the new column. The collection is what I want to retrieve from the database. You will see the select id="ticket_company" and name="ticket[company]", uses the controller (ticket) and the method (company) to create the form selection which it uses to post.Well, that's at least how I worked it out. (I may be incorrect in the , :firstname, :firstname ), but it works)
The :company was the new field in the form where I am using select and the column where the data must be placed in the database. Just for guidance, The old code made by the scaffold that I changed was:
<p>
<%= f.label :company %><br />
<%= f.text_field :company %>
</p>
It worked for me, hopefully someone ,looking for help finds it here as well. I am a absolute newbie to ruby and rails so its one of my best achievements to date. Cool!!
Gigg
Last edited by gigg (2008-11-10 07:37:00)