# Understanding the RoR API, noob questions here?

**URL:** <https://www.ruby-forum.com/t/understanding-the-ror-api-noob-questions-here/73996>\
**Category:** Rails\
**Created:** [October 29, 2006, 12:35am UTC](https://www.ruby-forum.com/t/understanding-the-ror-api-noob-questions-here/73996 "2006-10-29T00:35:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 29, 2006, 12:35am UTC](https://www.ruby-forum.com/t/understanding-the-ror-api-noob-questions-here/73996/1 "2006-10-29T00:35:06Z")

</div>

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”\>David  
select\_tag “people”, “David”  
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.

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 29, 2006, 3:00am UTC](https://www.ruby-forum.com/t/understanding-the-ror-api-noob-questions-here/73996/2 "2006-10-29T03:00:49Z")

</div>

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”\>David  
> select\_tag “people”, “David”  
> 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”, “3 minutes  
5 minutes  
7 minutes  
10 minutes  
15 minutes”

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 \<\< “#{category}” %\>  
\<% end %\>  
\<%= select\_tag “category”, option\_list -%\>

The “options” argument is ironically optional.

best,  
jp

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 29, 2006, 3:05am UTC](https://www.ruby-forum.com/t/understanding-the-ror-api-noob-questions-here/73996/3 "2006-10-29T03:05:28Z")

</div>

Jeff P. wrote:

> koloa wrote:
> 
> \<%= select\_tag “wait\_max”, “3 minutes  
> 5 minutes  
> 7 minutes  
> 10 minutes  
> 15 minutes”
> 
> 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 \<\< “#{category}” %\>  
> \<% end %\>  
> \<%= select\_tag “category”, option\_list -%\>
> 
> The “options” argument is ironically optional.
> 
> best,  
> jp

oops, 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

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [October 29, 2006, 3:22am UTC](https://www.ruby-forum.com/t/understanding-the-ror-api-noob-questions-here/73996/4 "2006-10-29T03:22:40Z")

</div>

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!
