Hi, Would someone be able to give me a quick example using select(), or point me to additional info? I''ve been trying to figure it out for awhile now. I''m sure it''s probably very easy and that I''m not in the right mindset. Originally I got stuck in this mindset that options = {} was for the actual <option></option> tags! :) Finally I realized that''s what the ''choices'' argument is for. What''s the best way to take the results from: @places = Place.find_all and use it with select()? I also can''t seem to figure out how to get the <option> to read <option value="id">value</option>. James
use collection_select <%= collection_select("job", "client" , @clients, "id", "name") %> @clients holds a collection of Client objects, id ends up being the value and name ends up being the text displayed this would create: <select name="job[client]"> <option value="1">Francisco Hernandez</option> <option value="2">James Earl</option> </select> James Earl wrote:> Hi, > > Would someone be able to give me a quick example using select(), or point me > to additional info? I''ve been trying to figure it out for awhile now. I''m > sure it''s probably very easy and that I''m not in the right mindset. > > Originally I got stuck in this mindset that options = {} was for the actual > <option></option> tags! :) Finally I realized that''s what the ''choices'' > argument is for. > > What''s the best way to take the results from: > > @places = Place.find_all > > and use it with select()? I also can''t seem to figure out how to get the > <option> to read <option value="id">value</option>. > > James > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Thank you for pointing me in the right direction. That worked perfectly. On January 29, 2005 5:43 pm, Francisco Hernandez wrote:> use collection_select > > <%= collection_select("job", "client" , @clients, "id", "name") %> > > @clients holds a collection of Client objects, id ends up being the > value and name ends up being the text displayed > > this would create: > > <select name="job[client]"> > <option value="1">Francisco Hernandez</option> > <option value="2">James Earl</option> > </select> > > James Earl wrote: > > Hi, > > > > Would someone be able to give me a quick example using select(), or point > > me to additional info? I''ve been trying to figure it out for awhile now. > > I''m sure it''s probably very easy and that I''m not in the right mindset. > > > > Originally I got stuck in this mindset that options = {} was for the > > actual <option></option> tags! :) Finally I realized that''s what the > > ''choices'' argument is for. > > > > What''s the best way to take the results from: > > > > @places = Place.find_all > > > > and use it with select()? I also can''t seem to figure out how to get the > > <option> to read <option value="id">value</option>. > > > > James > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails