sorry for another post. id really like to understand the documentation but this whole RoR stuff is nothing like c++. everything just magically happens using ror. my first question is this about the api... ////////////////////////// select_tag(name, option_tags = nil, options = {}) Creates a dropdown selection box, or if the :multiple option is set to true, a multiple choice selection box. Helpers::FormOptions can be used to create common select boxes such as countries, time zones, or associated records. option_tags is a string containing the option tags for the select box: # Outputs <select id="people" name="people"><option>David</option></select> select_tag "people", "<option>David</option>" Options: :multiple - If set to true the selection will allow multiple choices. ////////////////////// now i still dont understand what to substitue name, option_tags, options = {}) for. are these also found in the documentation. in c++ we call them arguments. i tried this <%= select_tag(''state'', option_tags = ''NJ'', options = {})%> in my form, but no drop down happens. thanks for any help. -- 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 -~----------~----~----~----~------~----~------~--~---
Jeff Pritchard
2006-Oct-29 00:00 UTC
Re: understanding the RoR API, noob questions here?...
koloa wrote:> sorry for another post. id really like to understand the documentation > but this whole RoR stuff is nothing like c++. everything just magically > happens using ror. > > my first question is this about the api... > ////////////////////////// > select_tag(name, option_tags = nil, options = {}) > Creates a dropdown selection box, or if the :multiple option is set to > true, a multiple choice selection box. > Helpers::FormOptions can be used to create common select boxes such as > countries, time zones, or associated records. > option_tags is a string containing the option tags for the select box: > # Outputs <select id="people" > name="people"><option>David</option></select> > select_tag "people", "<option>David</option>" > Options: > :multiple - If set to true the selection will allow multiple choices. > ////////////////////// > > > now i still dont understand what to substitue name, option_tags, options > = {}) for. are these also found in the documentation. in c++ we call > them arguments. > i tried this <%= select_tag(''state'', option_tags = ''NJ'', options = {})%> > in my form, but no drop down happens. > > thanks for any help.Hi Koloa, Just in general, it looks like maybe you are trying to learn Rails without looking at Ruby and HTML first. It can be done, but I think that is the hard way to learn it. The select_tag is a helper that builds some html for you based on what you feed it. If you wrote the html yourself by looking in an html book, it would be a "select tag" followed by several "option tags". The select tag helper just wants a string full of options like the following... <%= select_tag "wait_max", "<option>3 minutes</option> <option>5 minutes</option> <option>7 minutes</option> <option>10 minutes</option> <option>15 minutes</option>" In this case the string is being created "inline". Another way is to create the string first, such as by reading something from the database, and then feed that array variable as the argument: <% option_list = "" %> <% for category in Question.categories %> <% option_list << "<option>#{category}</option>" %> <% end %> <%= select_tag "category", option_list -%> The "options" argument is ironically optional. best, jp -- 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 -~----------~----~----~----~------~----~------~--~---
Jeff Pritchard
2006-Oct-29 02:05 UTC
Re: understanding the RoR API, noob questions here?...
Jeff Pritchard wrote:> koloa wrote: > > <%= select_tag "wait_max", "<option>3 minutes</option> > <option>5 minutes</option> > <option>7 minutes</option> > <option>10 minutes</option> > <option>15 minutes</option>" > > In this case the string is being created "inline". Another way is to > create the string first, such as by reading something from the database, > and then feed that array variable as the argument: > <% option_list = "" %> > <% for category in Question.categories %> > <% option_list << "<option>#{category}</option>" %> > <% end %> > <%= select_tag "category", option_list -%> > > The "options" argument is ironically optional. > > best, > jpoops, noticed two mistakes already. First, I left off the closing %> on the first example. Second, I should have said " and then feed that ''string'' variable as the argument:" just before the second example. jp -- 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 -~----------~----~----~----~------~----~------~--~---
hi jeff, thanks for the awesome reply. i see now that the helper methods help with creating html code. i guess in order to understand the ror functions, do like you suggest, and also understand the html. appreciate it, thanks! -- 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 -~----------~----~----~----~------~----~------~--~---