# Seledted option for select\_tag

**URL:** <https://www.ruby-forum.com/t/seledted-option-for-select-tag/147481>\
**Category:** Rails\
**Created:** [September 2, 2008, 10:36am UTC](https://www.ruby-forum.com/t/seledted-option-for-select-tag/147481 "2008-09-02T10:36:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lostwarrior](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@lostwarrior](https://www.ruby-forum.com/u/lostwarrior)\
**Post date:** [September 2, 2008, 10:36am UTC](https://www.ruby-forum.com/t/seledted-option-for-select-tag/147481/1 "2008-09-02T10:36:34Z")

</div>

Hi iam using select\_tag i want selected\_option. i have made select  
\_tag like this

\<%=select\_tag(‘name’, options\_for\_select({ :Relevance  
=\>‘Relevant’,:Date=\>‘Recent’}),:selected=\>params[:name].to\_s) %\>

The generated html look like this

Date

Relevance

How to make the selected option inside option tag

---

<div class="post-metadata">

**Author:** ![lostwarrior](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e57/32.png) [@lostwarrior](https://www.ruby-forum.com/u/lostwarrior)\
**Post date:** [September 2, 2008, 11:41am UTC](https://www.ruby-forum.com/t/seledted-option-for-select-tag/147481/2 "2008-09-02T11:41:51Z")

</div>

On 2 Sep 2008, at 09:36, Lost W. wrote:

> value=“Recent”\>Date
> 
> Relevance
> 
> How to make the selected option inside option tag

Well since selectedness is a property of an option not the select tag  
as a whole it makes sense for it to be an argument to  
options\_for\_select. Check the api for options\_for\_select

Fred/
