Hi there, I''m storing serveral values in my database through collection_select. Saving the value works fine but getting the saved value by using the update-form and setting it as "default-selected" doesn''t work. I tried :selected and :include_black till now... but nothing works. Can anyone help me? -- Posted via http://www.ruby-forum.com/.
On Jul 27, 5:41 am, Hans Hartmann <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi there, > > I''m storing serveral values in my database through collection_select. > Saving the value works fine but getting the saved value by using the > update-form and setting it as "default-selected" doesn''t work. > > I tried :selected and :include_black till now... but nothing works. >A classic is the selected values being _if fields (ie integers) but the choices being strings (and of course no 1 != "1") Fred> Can anyone help me? > -- > Posted viahttp://www.ruby-forum.com/.
Hmmm ... I can''t get this. I declared my choices as strings, but i don'' know how to set a DEFAULT-STRING.. something like <%= f.text_field :subject, :value => @ticket.subject%> just for collection_selct. Thx Frederick Cheung wrote:> On Jul 27, 5:41�am, Hans Hartmann <rails-mailing-l...@andreas-s.net> > wrote: >> Hi there, >> >> I''m storing serveral values in my database through collection_select. >> Saving the value works fine but getting the saved value by using the >> update-form and setting it as "default-selected" doesn''t work. >> >> I tried :selected and :include_black till now... but nothing works. >> > A classic is the selected values being _if fields (ie integers) but > the choices being strings (and of course no 1 != "1") > > Fred-- Posted via http://www.ruby-forum.com/.
On Jul 27, 8:26 am, Hans Hartmann <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hmmm ... I can''t get this. > I declared my choices as strings, but i don'' know how to set a > DEFAULT-STRING.. > something like > > <%= f.text_field :subject, :value => @ticket.subject%> > > just for collection_selct. >not sure collection_select takes a similar option. Given that it reads the current value out of the associated model object you could just set it there. Fred> Thx > > Frederick Cheung wrote: > > On Jul 27, 5:41 am, Hans Hartmann <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > >> Hi there, > > >> I''m storing serveral values in my database through collection_select. > >> Saving the value works fine but getting the saved value by using the > >> update-form and setting it as "default-selected" doesn''t work. > > >> I tried :selected and :include_black till now... but nothing works. > > > A classic is the selected values being _if fields (ie integers) but > > the choices being strings (and of course no 1 != "1") > > > Fred > > -- > Posted viahttp://www.ruby-forum.com/.
can anyone help me? -- Posted via http://www.ruby-forum.com/.
I understand you as wanting to have a default selection. If that''s correct then I would look into the options_for_select helper. It allows you to set a selected tag. Just make sure the selected object matches the type in your collection. Collection_select only selects the value if it was previously saved to the database. On Jul 27, 12:06 pm, Hans Hartmann <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> can anyone help me? > > -- > Posted viahttp://www.ruby-forum.com/.