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?
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?
(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.
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."
(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!
(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.
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?
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 ?
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?