{"id":588,"date":"2008-09-28T01:13:59","date_gmt":"2008-09-27T16:13:59","guid":{"rendered":"http:\/\/ecpplus.net\/weblog\/?p=588"},"modified":"2020-06-15T22:12:57","modified_gmt":"2020-06-15T13:12:57","slug":"url-for-on-rails","status":"publish","type":"post","link":"https:\/\/ecpplus.net\/weblog\/url-for-on-rails\/","title":{"rendered":"url_for \u306e\u3064\u307e\u305a\u304d\u3069\u3053\u308d"},"content":{"rendered":"<p>\u3000Rails \u3067\u4ee5\u4e0b\u306e\u30e1\u30bd\u30c3\u30c9\u3067 \u8a72\u5f53\u30a2\u30af\u30b7\u30e7\u30f3\u3078\u306e URL \u3092\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3051\u308c\u3069\u3082\u3001\u547c\u3076\u5834\u6240\u306b\u3088\u3063\u3066\u6319\u52d5\u304c\u9055\u3063\u3066\u3061\u3087\u3063\u3068\u3064\u307e\u305a\u3044\u305f\u3002<\/p>\n<pre lang=\"ruby\">url_for :controller => 'user', :action => 'show', :id => 100<\/pre>\n<p>\u52d5\u304b\u3057\u3066\u308b\u30b5\u30fc\u30d0\u304c http:\/\/localhost:3000 \u3068\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u69d8\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<dl>\n<dt>Controller\u5185<\/dt>\n<dd>http:\/\/localhost:3000\/user\/show\/100<\/dd>\n<dt>View, Helper\u5185<\/dt>\n<dd>\/user\/show\/100<\/dd>\n<\/dl>\n<p>View, Helper \u5185\u3067\u7d76\u5bfeURL \u3092\u3068\u308b\u306e\u306b\u4e00\u756a\u7c21\u5358\u305d\u3046\u306a\u306e\u306f\u3001config\/route.rb \u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u3001\u305d\u308c\u3092\u547c\u3076\u3068\u3044\u3046\u611f\u3058\u304b\u306a\u3041\u2026\u3002<\/p>\n<h4>config\/route.rb<\/h4>\n<pre lang=\"ruby\">ActionController::Routing::Routes.draw do |map|\n  map.user '\/user\/show\/:id', :controller => 'user', :action => 'show'\nend<\/pre>\n<h4>view\u3084helper\u3067<\/h4>\n<p>config\/route.rb \u3067 map.user \u3068\u5b9a\u7fa9\u3059\u308b\u3068\u3001user_url() \u304c\u5b9a\u7fa9\u3055\u308c\u3066\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u306e\u3067\u3001view\u3084helper \u3067\u4ee5\u4e0b\u306e\u611f\u3058\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3068\u7d76\u5bfeURL\u304c\u53d6\u308c\u307e\u3059\u3002<\/p>\n<pre lang=\"ruby\">user_url(:id => 100)<\/pre>\n<p>View \u304b\u3089\u7d76\u5bfeURL \u3092\u53d6\u308a\u305f\u3044\u3068\u3059\u308b\u3068\u3001\u3069\u3063\u304b\u5916\u90e8\u306b\u623b\u308aURL\u3092\u304f\u3063\u3064\u3051\u3066\u6295\u3052\u308b\u51e6\u7406\u306a\u3069\u3067\u4f7f\u3046\u304f\u3089\u3044\u3057\u304b\u601d\u3044\u3064\u304b\u306a\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000Rails \u3067\u4ee5\u4e0b\u306e\u30e1\u30bd\u30c3\u30c9\u3067 \u8a72\u5f53\u30a2\u30af\u30b7\u30e7\u30f3\u3078\u306e URL \u3092\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3051\u308c\u3069\u3082\u3001\u547c\u3076\u5834\u6240\u306b\u3088\u3063\u3066\u6319\u52d5\u304c\u9055\u3063\u3066\u3061\u3087\u3063\u3068\u3064\u307e\u305a\u3044\u305f\u3002 url_for :controller => &#8216;user&#8217;, :action [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2521,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[10],"class_list":["post-588","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-rails"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/comments?post=588"}],"version-history":[{"count":2,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/588\/revisions"}],"predecessor-version":[{"id":2549,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/588\/revisions\/2549"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media\/2521"}],"wp:attachment":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media?parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/categories?post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/tags?post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}