I''m trying to understand how to use the select, especially how to make an option selected. I want to add the values manually, but be sure one value is selected when finding an existing post in the db. How are you supposed to understand how to do that from this? http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000940 This is what I''ve used until now: <%= select ''user'', ''age'', ['''',''10-20'',''20-30'',''30-40'',''40-50'',''50-60'',''60-70'',''70+''] %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pål Bergström wrote:> I''m trying to understand how to use the select, especially how to make > an option selected. I want to add the values manually, but be sure one > value is selected when finding an existing post in the db. > > How are you supposed to understand how to do that from this? > > http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000940 > > This is what I''ve used until now: > > <%= select ''user'', ''age'', > ['''',''10-20'',''20-30'',''30-40'',''40-50'',''50-60'',''60-70'',''70+''] %>Got it. <%= select ''user'', ''age'', ['''',''10-20'',''20-30'',''30-40'',''40-50'',''50-60'',''60-70'',''70+''], :selected => @selected_value %> Is that described in the api? I can''t find it. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> <%= select ''user'', ''age'', > ['''',''10-20'',''20-30'',''30-40'',''40-50'',''50-60'',''60-70'',''70+''], :selected => > @selected_value %>> Is that described in the api? I can''t find it.Try select_tag (And note to whoever named a method ''select'' - please don''t!!!) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Try select_tag > > (And note to whoever named a method ''select'' - please don''t!!!)Does it say how to make a value selected? Can you add values manually like my example, without adding the actual option-tag? If not I don''t understand the point of using a ror select method instead of a regular html select. Why not use ''select''? It works fine. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This is the last sentence in the link you posted: "Specify :selected => value to use a different selection or :selected => nil to leave all options unselected." On May 17, 7:43 am, Pål Bergström <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Pål Bergström wrote: > > I''m trying to understand how to use the select, especially how to make > > an option selected. I want to add the values manually, but be sure one > > value is selected when finding an existing post in the db. > > > How are you supposed to understand how to do that from this? > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelp... > > > This is what I''ve used until now: > > > <%= select ''user'', ''age'', > > ['''',''10-20'',''20-30'',''30-40'',''40-50'',''50-60'',''60-70'',''70+''] %> > > Got it. > > <%= select ''user'', ''age'', > ['''',''10-20'',''20-30'',''30-40'',''40-50'',''50-60'',''60-70'',''70+''], :selected => > @selected_value %> > > Is that described in the api? I can''t find it. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
>> (And note to whoever named a method ''select'' - please don''t!!!)> Why not use ''select''? It works fine.Because programs must share a large namespace in memory, and a larger one in our brains. ''select'' is already used by Array, certain network sockets, and (in some languages) a keyword. Primitive things should have primeval names, such as ''select'', and complex & specific things should have decorated names. If all the other Rails HTML generators end in _tag, then select_ should too! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Phlip wrote:>>> (And note to whoever named a method ''select'' - please don''t!!!) > >> Why not use ''select''? It works fine. > > Because programs must share a large namespace in memory, and a larger > one in > our brains. ''select'' is already used by Array, certain network sockets, > and > (in some languages) a keyword. Primitive things should have primeval > names, > such as ''select'', and complex & specific things should have decorated > names. > If all the other Rails HTML generators end in _tag, then select_ should > too!I understand. But it must be a Rails-tag, otherwise it wouldn''t work. I just couldn''t get the select_tag to work with manual values. I mean what''s the point of using it, and some other rails-tags actually, when it''s as much hassle to write the html-tag? I think this is a good example of the backside of Rails, the documentation. I wonder if they plan to update it? Wouldn''t hurt if they did. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Actually a rails documentation project has been around for a while now. In fact, not only is it around but its open to whoever wants to help improve the documentation. Anyone can get commit rights so you can make changes and add them directly into this which will then be merged back into rails. In fact, I strongly encourage you to take this into your own hands. Is there a part of rails that is poorly documented? http://github.com/lifo/docrails/tree/master You can make it right. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 17 May 2008, at 21:03, Phlip wrote:> >>> (And note to whoever named a method ''select'' - please don''t!!!) > >> Why not use ''select''? It works fine. > > Because programs must share a large namespace in memory, and a > larger one in > our brains. ''select'' is already used by Array, certain network > sockets, and > (in some languages) a keyword. Primitive things should have primeval > names, > such as ''select'', and complex & specific things should have > decorated names. > If all the other Rails HTML generators end in _tag, then select_ > should too!There is a select_tag helper, which is different. In the same way that the raw check_box_tag, text_field_tag have equivalents without the _tag that operate on a controller instance variable, select_tag''s equivalent is plain old select. select can mean a bunch of different things but then again we frequently overload operators, so why not method names too ? Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nathan Esquenazi wrote:> Actually a rails documentation project has been around for a while now. > In fact, not only is it around but its open to whoever wants to help > improve the documentation. Anyone can get commit rights so you can make > changes and add them directly into this which will then be merged back > into rails. > > In fact, I strongly encourage you to take this into your own hands. Is > there a part of rails that is poorly documented? > > http://github.com/lifo/docrails/tree/master > > You can make it right.Good to know. Not a git user though. Maybe this will pull me into version control. I haven''t found it valuable yet. I''ll take a look. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 17 May 2008, at 21:03, Phlip wrote: >> > There is a select_tag helper, which is different. In the same way that > the raw check_box_tag, text_field_tag have equivalents without the > _tag that operate on a controller instance variable, select_tag''s > equivalent is plain old select. select can mean a bunch of different > things but then again we frequently overload operators, so why not > method names too ? > > FredTrue. Thanks for the clarification. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---