<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>anton0825</author_name>
  <author_url>https://blog.hatena.ne.jp/anton0825/</author_url>
  <blog_title>日々精進</blog_title>
  <blog_url>https://anton0825.hatenablog.com/</blog_url>
  <categories>
    <anon>IT</anon>
  </categories>
  <description>collection_selectを使えばドロップダウンリストが作れるのだが、どの要素をSelectedにするかをどう指定すればいいかがちょっとわかりにくい。 ↓のような感じでoption引数の位置にselected要素をハッシュに詰めて渡すと指定できました。 &lt;% fields_for :employee do |f| %&gt; &lt;%= f.collection_select :shozoku_id, Shozoku.find(:all, :order =&gt; 'name asc'), :id, :name, {:selected =&gt; (f.shozoku_id)} %&gt; &lt;% end %&gt; ↓…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fanton0825.hatenablog.com%2Fentry%2F20100502%2F1272975544&quot; title=&quot;RailsでドロップダウンリストのSelected要素を指定する - 日々精進&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2010-05-02 21:19:04</published>
  <title>RailsでドロップダウンリストのSelected要素を指定する</title>
  <type>rich</type>
  <url>https://anton0825.hatenablog.com/entry/20100502/1272975544</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
