---
title: "select_tag default value & options"
author: "夜鸣猪"
date: "2013-04-10T21:40:04Z"
tags: []
categories: ["编程语言"]
slug: "select-tag-default-value-options"
draft: false
lastmod: "2013-04-10T21:40:04Z"
id: 1845392
url: "https://hlee.iteye.com/blog/1845392"
---

```ruby

#If you are using select_tag without any other helper, then you can do it in html:

select_tag "whatever", "<option>VISA</option><option selected=\"selected\">MasterCard</option>"

#Or with options_for_select:

select_tag "whatever", options_for_select([ "visa", "mastercard" ], "MasterCard")

#Or with options_from_collection_for_select:

select_tag "people", options_from_collection_for_select(@people, 'id', 'name', '1')

#Examples are from select_tag doc, options_for_select doc and from options_from_collection_for_select doc.



```