{"id":57367,"date":"2022-12-27T09:19:11","date_gmt":"2022-12-27T00:19:11","guid":{"rendered":"https://freelance.indieverse.co.jp/media/?p=57367"},"modified":"2026-06-08T16:08:29","modified_gmt":"2026-06-08T07:08:29","slug":"ruby-get-url-parameter","status":"publish","type":"post","link":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter","title":{"rendered":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する"},"content":{"rendered":"<p>この記事では、Rubyを用いて、以下のようなURLから、特定のパラメーターの値を取得する方法について記載します。</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code># idとempidを取得する</code>url = 'http://www.example.com?id=4&amp;empid=6'</pre>\n</div>\n<p>結論、以下のように取得可能です。</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>url = Addressable::URI.parse('http://www.example.com?id=4&amp;empid=6')\r\nurl.query_values # {\"id\"=&gt;\"4\", \"empid\"=&gt;\"6\"}</code></pre>\n</div>\n<h2>環境</h2>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>rails -v\r\nRails 7.0.4\r\nruby -v\r\nruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x86_64-linux]</code></pre>\n</div>\n<h2>RubyでURLパラメーターを取得する方法</h2>\n<p>Rubyでは、URLを取得するライブラリに、以下のようなものがあります。</p>\n<ul>\n<li><a href=\"https://github.com/ruby/uri\">URI</a></li>\n<li><a href=\"https://github.com/sporkmonger/addressable\">Addressable</a></li>\n</ul>\n<p>AddressableはURIの後継だそうです。</p>\n<p>URLとAddressableがありますが、個人的にはURLパラメーターの取り扱いがAdderssableの方が体験としてよかったため、Addressableを利用して、以下の値を取得する方法について見ていきます。</p>\n<p>※詳しくはAddressableのGithubに詳しい解説が書いてあるため、参照してください。</p>\n<p><a href=\"https://github.com/sporkmonger/addressable\">https://github.com/sporkmonger/addressable</a></p>\n<h2>Gem Addressableのインストール</h2>\n<p>まず、AddressableのGemをインストールします。</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>$ gem install addressable\r\n</code></pre>\n</div>\n<h2>URLパラメーターの取得</h2>\n<p>次に、</p>\n<ul>\n<li>id</li>\n<li>empid</li>\n</ul>\n<p>の取得をしていきます。</p>\n<p>URLをパースした値に対して、<code>query_values</code>メソッドを呼ぶことで、ハッシュ形式でURLパラメーターを取得してくれます。</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>url = Addressable::URI.parse('http://www.example.com?id=4&amp;empid=6')\r\n# query_valuesを利用すると、ハッシュでURLパラメーターを取得してくれる\r\nurl.query_values # {\"id\"=&gt;\"4\", \"empid\"=&gt;\"6\"}</code></pre>\n</div>\n<p>非常に簡単でした。</p>\n<h2>スキーマの取得</h2>\n<p>URLから、</p>\n<ul>\n<li>http</li>\n<li>https</li>\n</ul>\n<p>などの値を取得したい場合は、<code>schema</code>を指定することで取得可能です。</p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>uri = Addressable::URI.parse(\"http://example.com/path/to/resource/\")\r\nuri.scheme\r\n#=&gt; \"http\"</code></pre>\n<h2>ドメインの取得</h2>\n<p>URLから、</p>\n<ul>\n<li>example.com</li>\n</ul>\n<p>の値を取得したい場合は、<code>host</code>を指定することで取得可能です。</p>\n</div>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>uri = Addressable::URI.parse(\"http://example.com/path/to/resource/\")\r\nuri.host\r\n#=&gt; \"example.com\"</code></pre>\n<h2>相対パスの取得</h2>\n<p>URLから、</p>\n<ul>\n<li>/path/to/resource/</li>\n</ul>\n<p>を取得したい場合、<code>path</code>を指定することで取得できます。</p>\n</div>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\"><code>uri = Addressable::URI.parse(\"http://example.com/path/to/resource/\")\r\nuri.path\r\n#=&gt; \"/path/to/resource/\"</code></pre>\n</div>\n<div class=\"hcb_wrap\">\n<h2>備考：URIとの比較</h2>\n</div>\n<p>URIでも同じようなことを行うことができるのですが、個人的にはAddressableの方がURLパラメーターの取得が楽でした。</p>\n<p>参考までにURIのGithubのサンプルコードを掲載しておきます。</p>\n<p>URI:<br />\n<a href=\"https://github.com/ruby/uri\">https://github.com/ruby/uri</a></p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-ruby\" data-lang=\"Ruby\">require \"uri\"\r\nuri = URI(\"http://foo.com/posts?id=30&amp;limit=5#time=1305298413\")\r\n#=&gt; #&lt;URI::HTTP http://foo.com/posts?id=30&amp;limit=5#time=1305298413&gt;\r\nuri.scheme #=&gt; \"http\" #スキーマの取得\r\nuri.host #=&gt; \"foo.com\" #ドメインの取得\r\nuri.path #=&gt; \"/posts\" #パスの取得\r\nuri.query #=&gt; \"id=30&amp;limit=5\" #URLパラメーターの取得\r\nuri.fragment #=&gt; \"time=1305298413\"\r\n<code></code></pre>\n</div>\n<div class=\"hcb_wrap\">\n<h2>参考</h2>\n</div>\n<ul>\n<li><a href=\"https://stackoverflow.com/questions/7316656/how-to-get-a-query-string-from-a-url-in-rails\">https://stackoverflow.com/questions/7316656/how-to-get-a-query-string-from-a-url-in-rails</a></li>\n<li><a href=\"https://github.com/sporkmonger/addressable\">https://github.com/sporkmonger/addressable</a></li>\n</ul>\n<h2>URLパラメーター処理をRails案件で活かすには</h2>\n<p>URLパラメーターの取得は、Ruby on Railsの実務でも検索機能、絞り込み、ページネーション、広告計測、外部サービス連携などで使われます。Railsでは<code>params</code>で扱う場面が多いものの、URLを直接パースする処理を理解しておくと、Webアプリのリクエスト処理をより深く理解できます。</p>\n<p>RailsのWebアプリ開発でどのような機能実装が求められているかを知りたい場合は、<a href=\"https://freelance.indieverse.co.jp/job_listings/skills/389\">Ruby on Rails案件一覧</a>で、実際の案件内容や必要スキルを確認してみましょう。</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>\n","protected":false},"excerpt":{"rendered":"<p>RubyでURLパラメーター取得を解説。Addressableのquery_valuesでidやempidを取得し、schemeやhost、pathの取得とURIとの違いも説明します。</p>\n","protected":false},"author":1,"featured_media":56300,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[190],"tags":[],"class_list":["post-57367","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"RubyでURLパラメーター取得を解説。Addressableのquery_valuesでidやempidを取得し、schemeやhost、pathの取得とURIとの違いも説明します。\" />\n\t<meta name=\"robots\" content=\"max-image-preview:large\" />\n\t<meta name=\"author\" content=\"DAI\"/>\n\t<link rel=\"canonical\" href=\"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter\" />\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" />\n\t\t<meta property=\"og:locale\" content=\"ja_JP\" />\n\t\t<meta property=\"og:site_name\" content=\"インディバースフリーランスメディア - Indieverse Freelanceの公式メディアです\" />\n\t\t<meta property=\"og:type\" content=\"article\" />\n\t\t<meta property=\"og:title\" content=\"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する - インディバースフリーランスメディア\" />\n\t\t<meta property=\"og:description\" content=\"RubyでURLパラメーター取得を解説。Addressableのquery_valuesでidやempidを取得し、schemeやhost、pathの取得とURIとの違いも説明します。\" />\n\t\t<meta property=\"og:url\" content=\"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter\" />\n\t\t<meta property=\"article:published_time\" content=\"2022-12-27T00:19:11+00:00\" />\n\t\t<meta property=\"article:modified_time\" content=\"2026-06-08T07:08:29+00:00\" />\n\t\t<meta name=\"twitter:card\" content=\"summary\" />\n\t\t<meta name=\"twitter:title\" content=\"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する - インディバースフリーランスメディア\" />\n\t\t<meta name=\"twitter:description\" content=\"RubyでURLパラメーター取得を解説。Addressableのquery_valuesでidやempidを取得し、schemeやhost、pathの取得とURIとの違いも説明します。\" />\n\t\t<script type=\"application/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\/\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter#blogposting\",\"name\":\"Ruby\\u3067URL\\u30d1\\u30e9\\u30e1\\u30fc\\u30bf\\u30fc\\u306e\\u5024\\u3092\\u53d6\\u5f97\\u3059\\u308b\\u65b9\\u6cd5 | Addressable\\u3092\\u5229\\u7528\\u3057\\u3066\\u53d6\\u5f97\\u3059\\u308b - \\u30a4\\u30f3\\u30c7\\u30a3\\u30d0\\u30fc\\u30b9\\u30d5\\u30ea\\u30fc\\u30e9\\u30f3\\u30b9\\u30e1\\u30c7\\u30a3\\u30a2\",\"headline\":\"Ruby\\u3067URL\\u30d1\\u30e9\\u30e1\\u30fc\\u30bf\\u30fc\\u306e\\u5024\\u3092\\u53d6\\u5f97\\u3059\\u308b\\u65b9\\u6cd5 | Addressable\\u3092\\u5229\\u7528\\u3057\\u3066\\u53d6\\u5f97\\u3059\\u308b\",\"author\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster#author\"},\"publisher\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\/\\/freelance.dividable.net\\/wp-content\\/uploads\\/2022\\/12\\/iocenters-gcd591ea11_1280.jpg\",\"width\":1280,\"height\":853},\"datePublished\":\"2022-12-27T09:19:11+09:00\",\"dateModified\":\"2026-06-08T16:08:29+09:00\",\"inLanguage\":\"ja\",\"mainEntityOfPage\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter#webpage\"},\"isPartOf\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter#webpage\"},\"articleSection\":\"Ruby\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/#listItem\",\"position\":1,\"name\":\"\\u30db\\u30fc\\u30e0\",\"item\":\"https:\\/\\/freelance.dividable.net\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming#listItem\",\"name\":\"\\u30d7\\u30ed\\u30b0\\u30e9\\u30df\\u30f3\\u30b0\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming#listItem\",\"position\":2,\"name\":\"\\u30d7\\u30ed\\u30b0\\u30e9\\u30df\\u30f3\\u30b0\",\"item\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\\/ruby#listItem\",\"name\":\"Ruby\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/#listItem\",\"name\":\"\\u30db\\u30fc\\u30e0\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\\/ruby#listItem\",\"position\":3,\"name\":\"Ruby\",\"item\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\\/ruby\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter#listItem\",\"name\":\"Ruby\\u3067URL\\u30d1\\u30e9\\u30e1\\u30fc\\u30bf\\u30fc\\u306e\\u5024\\u3092\\u53d6\\u5f97\\u3059\\u308b\\u65b9\\u6cd5 | Addressable\\u3092\\u5229\\u7528\\u3057\\u3066\\u53d6\\u5f97\\u3059\\u308b\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming#listItem\",\"name\":\"\\u30d7\\u30ed\\u30b0\\u30e9\\u30df\\u30f3\\u30b0\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter#listItem\",\"position\":4,\"name\":\"Ruby\\u3067URL\\u30d1\\u30e9\\u30e1\\u30fc\\u30bf\\u30fc\\u306e\\u5024\\u3092\\u53d6\\u5f97\\u3059\\u308b\\u65b9\\u6cd5 | Addressable\\u3092\\u5229\\u7528\\u3057\\u3066\\u53d6\\u5f97\\u3059\\u308b\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/category\\/programming\\/ruby#listItem\",\"name\":\"Ruby\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/#organization\",\"name\":\"Indieverse Freelance\",\"description\":\"Indieverse Freelance\\u306e\\u516c\\u5f0f\\u30e1\\u30c7\\u30a3\\u30a2\\u3067\\u3059\",\"url\":\"https:\\/\\/freelance.dividable.net\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster#author\",\"url\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster\",\"name\":\"DAI\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter#webpage\",\"url\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter\",\"name\":\"Ruby\\u3067URL\\u30d1\\u30e9\\u30e1\\u30fc\\u30bf\\u30fc\\u306e\\u5024\\u3092\\u53d6\\u5f97\\u3059\\u308b\\u65b9\\u6cd5 | Addressable\\u3092\\u5229\\u7528\\u3057\\u3066\\u53d6\\u5f97\\u3059\\u308b - \\u30a4\\u30f3\\u30c7\\u30a3\\u30d0\\u30fc\\u30b9\\u30d5\\u30ea\\u30fc\\u30e9\\u30f3\\u30b9\\u30e1\\u30c7\\u30a3\\u30a2\",\"description\":\"Ruby\\u3067URL\\u30d1\\u30e9\\u30e1\\u30fc\\u30bf\\u30fc\\u53d6\\u5f97\\u3092\\u89e3\\u8aac\\u3002Addressable\\u306equery_values\\u3067id\\u3084empid\\u3092\\u53d6\\u5f97\\u3057\\u3001scheme\\u3084host\\u3001path\\u306e\\u53d6\\u5f97\\u3068URI\\u3068\\u306e\\u9055\\u3044\\u3082\\u8aac\\u660e\\u3057\\u307e\\u3059\\u3002\",\"inLanguage\":\"ja\",\"isPartOf\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter#breadcrumblist\"},\"author\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster#author\"},\"creator\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/author\\/wpmaster#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\/\\/freelance.dividable.net\\/wp-content\\/uploads\\/2022\\/12\\/iocenters-gcd591ea11_1280.jpg\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter\\/#mainImage\",\"width\":1280,\"height\":853},\"primaryImageOfPage\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/programming\\/ruby\\/ruby-get-url-parameter#mainImage\"},\"datePublished\":\"2022-12-27T09:19:11+09:00\",\"dateModified\":\"2026-06-08T16:08:29+09:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\/\\/freelance.dividable.net\\/#website\",\"url\":\"https:\\/\\/freelance.dividable.net\\/\",\"name\":\"\\u30a4\\u30f3\\u30c7\\u30a3\\u30d0\\u30fc\\u30b9\\u30d5\\u30ea\\u30fc\\u30e9\\u30f3\\u30b9\\u30e1\\u30c7\\u30a3\\u30a2\",\"description\":\"Indieverse Freelance\\u306e\\u516c\\u5f0f\\u30e1\\u30c7\\u30a3\\u30a2\\u3067\\u3059\",\"inLanguage\":\"ja\",\"publisher\":{\"@id\":\"https:\\/\\/freelance.dividable.net\\/#organization\"}}]}\n\t\t</script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する - インディバースフリーランスメディア","description":"RubyでURLパラメーター取得を解説。Addressableのquery_valuesでidやempidを取得し、schemeやhost、pathの取得とURIとの違いも説明します。","canonical_url":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https://schema.org","@graph":[{"@type":"BlogPosting","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter#blogposting","name":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する - インディバースフリーランスメディア","headline":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する","author":{"@id":"https://freelance.indieverse.co.jp/media/author/wpmaster#author"},"publisher":{"@id":"https://freelance.indieverse.co.jp/media/#organization"},"image":{"@type":"ImageObject","url":"https://freelance.indieverse.co.jp/media/wp-content/uploads/2022/12/iocenters-gcd591ea11_1280.jpg","width":1280,"height":853},"datePublished":"2022-12-27T09:19:11+09:00","dateModified":"2026-06-08T16:08:29+09:00","inLanguage":"ja","mainEntityOfPage":{"@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter#webpage"},"isPartOf":{"@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter#webpage"},"articleSection":"Ruby"},{"@type":"BreadcrumbList","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/#listItem","position":1,"name":"ホーム","item":"https://freelance.indieverse.co.jp/media/","nextItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming#listItem","name":"プログラミング"}},{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming#listItem","position":2,"name":"プログラミング","item":"https://freelance.indieverse.co.jp/media/category/programming","nextItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming/ruby#listItem","name":"Ruby"},"previousItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/#listItem","name":"ホーム"}},{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming/ruby#listItem","position":3,"name":"Ruby","item":"https://freelance.indieverse.co.jp/media/category/programming/ruby","nextItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter#listItem","name":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する"},"previousItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming#listItem","name":"プログラミング"}},{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter#listItem","position":4,"name":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する","previousItem":{"@type":"ListItem","@id":"https://freelance.indieverse.co.jp/media/category/programming/ruby#listItem","name":"Ruby"}}]},{"@type":"Organization","@id":"https://freelance.indieverse.co.jp/media/#organization","name":"Indieverse Freelance","description":"Indieverse Freelanceの公式メディアです","url":"https://freelance.indieverse.co.jp/media/"},{"@type":"Person","@id":"https://freelance.indieverse.co.jp/media/author/wpmaster#author","url":"https://freelance.indieverse.co.jp/media/author/wpmaster","name":"DAI"},{"@type":"WebPage","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter#webpage","url":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter","name":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する - インディバースフリーランスメディア","description":"RubyでURLパラメーター取得を解説。Addressableのquery_valuesでidやempidを取得し、schemeやhost、pathの取得とURIとの違いも説明します。","inLanguage":"ja","isPartOf":{"@id":"https://freelance.indieverse.co.jp/media/#website"},"breadcrumb":{"@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter#breadcrumblist"},"author":{"@id":"https://freelance.indieverse.co.jp/media/author/wpmaster#author"},"creator":{"@id":"https://freelance.indieverse.co.jp/media/author/wpmaster#author"},"image":{"@type":"ImageObject","url":"https://freelance.indieverse.co.jp/media/wp-content/uploads/2022/12/iocenters-gcd591ea11_1280.jpg","@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter/#mainImage","width":1280,"height":853},"primaryImageOfPage":{"@id":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter#mainImage"},"datePublished":"2022-12-27T09:19:11+09:00","dateModified":"2026-06-08T16:08:29+09:00"},{"@type":"WebSite","@id":"https://freelance.indieverse.co.jp/media/#website","url":"https://freelance.indieverse.co.jp/media/","name":"インディバースフリーランスメディア","description":"Indieverse Freelanceの公式メディアです","inLanguage":"ja","publisher":{"@id":"https://freelance.indieverse.co.jp/media/#organization"}}]},"og:locale":"ja_JP","og:site_name":"インディバースフリーランスメディア - Indieverse Freelanceの公式メディアです","og:type":"article","og:title":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する - インディバースフリーランスメディア","og:description":"RubyでURLパラメーター取得を解説。Addressableのquery_valuesでidやempidを取得し、schemeやhost、pathの取得とURIとの違いも説明します。","og:url":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter","article:published_time":"2022-12-27T00:19:11+00:00","article:modified_time":"2026-06-08T07:08:29+00:00","twitter:card":"summary","twitter:title":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する - インディバースフリーランスメディア","twitter:description":"RubyでURLパラメーター取得を解説。Addressableのquery_valuesでidやempidを取得し、schemeやhost、pathの取得とURIとの違いも説明します。"},"aioseo_meta_data":{"post_id":"57367","title":null,"description":null,"keywords":null,"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":{"id":"#aioseo-article-67f5c46b676fc","slug":"article","graphName":"Article","label":"記事","properties":{"type":"BlogPosting","name":"#post_title","headline":"#post_title","description":"#post_excerpt","image":"","keywords":"","author":{"name":"#author_name","url":"#author_url"},"dates":{"include":true,"datePublished":"","dateModified":""}}},"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"limit_modified_date":false,"created":"2022-12-26 23:56:58","updated":"2025-09-08 22:46:58","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https://freelance.indieverse.co.jp/media/\" title=\"ホーム\">ホーム</a>\n\t\t</span><span class=\"aioseo-breadcrumb-separator\">»</span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https://freelance.indieverse.co.jp/media/category/programming\" title=\"プログラミング\">プログラミング</a>\n\t\t</span><span class=\"aioseo-breadcrumb-separator\">»</span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https://freelance.indieverse.co.jp/media/category/programming/ruby\" title=\"Ruby\">Ruby</a>\n\t\t</span><span class=\"aioseo-breadcrumb-separator\">»</span><span class=\"aioseo-breadcrumb\">\n\t\t\tRubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する\n\t\t</span></div>","aioseo_breadcrumb_json":[{"label":"ホーム","link":"https://freelance.indieverse.co.jp/media/"},{"label":"プログラミング","link":"https://freelance.indieverse.co.jp/media/category/programming"},{"label":"Ruby","link":"https://freelance.indieverse.co.jp/media/category/programming/ruby"},{"label":"RubyでURLパラメーターの値を取得する方法 | Addressableを利用して取得する","link":"https://freelance.indieverse.co.jp/media/programming/ruby/ruby-get-url-parameter"}],"meta_description":"RubyでURLパラメーター取得を解説。Addressableのquery_valuesでidやempidを取得し、schemeやhost、pathの取得とURIとの違いも説明します。","_links":{"self":[{"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/posts/57367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/posts"}],"about":[{"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/types/post"}],"author":[{"embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/users/1"}],"replies":[{"embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/comments?post=57367"}],"version-history":[{"count":3,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/posts/57367/revisions"}],"predecessor-version":[{"id":96840,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/posts/57367/revisions/96840"}],"wp:featuredmedia":[{"embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/media/56300"}],"wp:attachment":[{"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/media?parent=57367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/categories?post=57367"},{"taxonomy":"post_tag","embeddable":true,"href":"https://freelance.indieverse.co.jp/media/wp-json/wp/v2/tags?post=57367"}],"curies":[{"name":"wp","href":"https://api.w.org/{rel}","templated":true}]}}