Pål Bergström | 17 May 13:18

Select and how to read the api


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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Pål Bergström | 17 May 13:43

Re: Select and how to read the api


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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
(Continue reading)

Phlip | 17 May 15:00

Re: Select and how to read the api


> <%= 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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Pål Bergström | 17 May 15:16

Re: Select and how to read the api


> 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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Phlip | 17 May 22:03

Re: Select and how to read the api


>> (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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Pål Bergström | 17 May 22:20

Re: Select and how to read the api


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/.

--~--~---------~--~----~------------~-------~--~----~
(Continue reading)

Nathan Esquenazi | 18 May 01:35

Re: Select and how to read the api


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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Pål Bergström | 18 May 09:28

Re: Select and how to read the api


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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Frederick Cheung | 18 May 02:44

Re: Select and how to read the api


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.
(Continue reading)

Pål Bergström | 18 May 09:30

Re: Select and how to read the api


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 ?
> 
> Fred

True. 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@...
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Zach | 17 May 19:42

Re: Select and how to read the api


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...@...>
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/.
(Continue reading)


Gmane