Hi, I have this code: <%= debug @deposit.to_user_id %> <%= select("deposit", "to_user_id", User.find_all.collect {|u| [ u.fullname, u.id.to_s ] }, {:prompt => ''Select a user'', :selected => @deposit.to_user_id} ) %> It generates this: --- 2 <select id="deposit_to_user_id" name="deposit[to_user_id]"><option value="1">Leon Bogaert</option> <option value="2">Gijs Everaard</option></select> Why doesn''t it generate the prompt and the selected? With kind regards, Leon Bogaert --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Anyone? If I change the to_user_id in user_id it works. But that requires a change in the database and makes the whole just less readable. Especially because there''s another field called from_user_id. On Mar 14, 11:44 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> Hi, > > I have this code: > <%= debug @deposit.to_user_id %> > <%= select("deposit", "to_user_id", User.find_all.collect {|u| > [ u.fullname, u.id.to_s ] }, {:prompt => ''Select a user'', :selected => > @deposit.to_user_id} ) %> > > It generates this: > --- 2 > <select id="deposit_to_user_id" name="deposit[to_user_id]"><option > value="1">Leon Bogaert</option> > <option value="2">Gijs Everaard</option></select> > > Why doesn''t it generate the prompt and the selected? > > With kind regards, > Leon Bogaert--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe there''s anoyher way of achieving the same? On Mar 15, 9:12 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> Anyone? If I change the to_user_id in user_id it works. But that > requires a change in the database and makes the whole just less > readable. Especially because there''s another field called > from_user_id. > > On Mar 14, 11:44 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > Hi, > > > I have this code: > > <%= debug @deposit.to_user_id %> > > <%= select("deposit", "to_user_id", User.find_all.collect {|u| > > [ u.fullname, u.id.to_s ] }, {:prompt => ''Select a user'', :selected => > > @deposit.to_user_id} ) %> > > > It generates this: > > --- 2 > > <select id="deposit_to_user_id" name="deposit[to_user_id]"><option > > value="1">Leon Bogaert</option> > > <option value="2">Gijs Everaard</option></select> > > > Why doesn''t it generate the prompt and the selected? > > > With kind regards, > > Leon Bogaert--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ahh... got it. This worked: <%= collection_select("deposit", "to_user_id", User.find_all, "id", "fullname", :selected => "to_user_id") %> But now :prompt does not work anymore.... <%= collection_select("deposit", "to_user_id", User.find_all, "id", "fullname", :selected => "to_user_id", :prompt => "This is a test") %> On Mar 15, 8:49 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> Maybe there''s anoyher way of achieving the same? > > On Mar 15, 9:12 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > Anyone? If I change the to_user_id in user_id it works. But that > > requires a change in the database and makes the whole just less > > readable. Especially because there''s another field called > > from_user_id. > > > On Mar 14, 11:44 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > > Hi, > > > > I have this code: > > > <%= debug @deposit.to_user_id %> > > > <%= select("deposit", "to_user_id", User.find_all.collect {|u| > > > [ u.fullname, u.id.to_s ] }, {:prompt => ''Select a user'', :selected => > > > @deposit.to_user_id} ) %> > > > > It generates this: > > > --- 2 > > > <select id="deposit_to_user_id" name="deposit[to_user_id]"><option > > > value="1">Leon Bogaert</option> > > > <option value="2">Gijs Everaard</option></select> > > > > Why doesn''t it generate the prompt and the selected? > > > > With kind regards, > > > Leon Bogaert--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ah.... This works: <%= collection_select("deposit", "to_user_id", User.find_all, "id", "fullname", {:prompt => ''Dit is een test''} ) %> if to_user_id would not be "0". It''s an integer and probably it''s zero to default. Can I change this behaviour? Else the selectlist won''t work. And setting it to '''' before each selectlist seems like a crappy solution. On Mar 15, 9:15 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> Ahh... got it. This worked: > <%= collection_select("deposit", "to_user_id", User.find_all, "id", > "fullname", :selected => "to_user_id") %> > > But now :prompt does not work anymore.... > <%= collection_select("deposit", "to_user_id", User.find_all, "id", > "fullname", :selected => "to_user_id", :prompt => "This is a test") > %> > > On Mar 15, 8:49 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > Maybe there''s anoyher way of achieving the same? > > > On Mar 15, 9:12 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > > Anyone? If I change the to_user_id in user_id it works. But that > > > requires a change in the database and makes the whole just less > > > readable. Especially because there''s another field called > > > from_user_id. > > > > On Mar 14, 11:44 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > > > Hi, > > > > > I have this code: > > > > <%= debug @deposit.to_user_id %> > > > > <%= select("deposit", "to_user_id", User.find_all.collect {|u| > > > > [ u.fullname, u.id.to_s ] }, {:prompt => ''Select a user'', :selected => > > > > @deposit.to_user_id} ) %> > > > > > It generates this: > > > > --- 2 > > > > <select id="deposit_to_user_id" name="deposit[to_user_id]"><option > > > > value="1">Leon Bogaert</option> > > > > <option value="2">Gijs Everaard</option></select> > > > > > Why doesn''t it generate the prompt and the selected? > > > > > With kind regards, > > > > Leon Bogaert--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ah got it.... Yes again.... table.column :to_user_id, :integer, :default => nil does it On Mar 15, 9:29 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> Ah.... > This works: > <%= collection_select("deposit", "to_user_id", User.find_all, "id", > "fullname", {:prompt => ''Dit is een test''} ) %> > > if to_user_id would not be "0". It''s an integer and probably it''s zero > to default. Can I change this behaviour? Else the selectlist won''t > work. And setting it to '''' before each selectlist seems like a crappy > solution. > > On Mar 15, 9:15 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > Ahh... got it. This worked: > > <%= collection_select("deposit", "to_user_id", User.find_all, "id", > > "fullname", :selected => "to_user_id") %> > > > But now :prompt does not work anymore.... > > <%= collection_select("deposit", "to_user_id", User.find_all, "id", > > "fullname", :selected => "to_user_id", :prompt => "This is a test") > > %> > > > On Mar 15, 8:49 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > > Maybe there''s anoyher way of achieving the same? > > > > On Mar 15, 9:12 am, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > > > Anyone? If I change the to_user_id in user_id it works. But that > > > > requires a change in the database and makes the whole just less > > > > readable. Especially because there''s another field called > > > > from_user_id. > > > > > On Mar 14, 11:44 pm, "LeonB" <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote: > > > > > > Hi, > > > > > > I have this code: > > > > > <%= debug @deposit.to_user_id %> > > > > > <%= select("deposit", "to_user_id", User.find_all.collect {|u| > > > > > [ u.fullname, u.id.to_s ] }, {:prompt => ''Select a user'', :selected => > > > > > @deposit.to_user_id} ) %> > > > > > > It generates this: > > > > > --- 2 > > > > > <select id="deposit_to_user_id" name="deposit[to_user_id]"><option > > > > > value="1">Leon Bogaert</option> > > > > > <option value="2">Gijs Everaard</option></select> > > > > > > Why doesn''t it generate the prompt and the selected? > > > > > > With kind regards, > > > > > Leon Bogaert--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---