1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

孤独アドベントカレンダーに挑戦Advent Calendar 2019

Day 11

rails routesのdirect resolveメモ

Last updated at Posted at 2019-12-10

概要

direct routing

アプリ外のルーティングをroutes.rbで表現できるようになった事で、
アプリ内外問わず、ルーティングをroutes.rbに集約できるようなった。

resolve routing

動的に変わるurl_helper
モデルに応じたポリモーフィックなURL生成のルールを再定義できるようになった。

使い方

direct routing

config/routes.rb
direct :outside do
  { controller: '', action: '' }
  'https://outside.com'
end


# >> outside_url
# => "https://outside.com"

direct :homepage do
  "http://www.rubyonrails.org"
end

# >> homepage_url
# => "http://www.rubyonrails.org"

resolve routing

config/routes.rb
resource :basket
 
resolve("Basket") { [:basket] }
<%= form_for @basket do |form| %>
  <!-- basket form -->
<% end %>

背景

ドキュメント

direct routing

resolve routing

実装

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?