1
0

More than 1 year has passed since last update.

サブドメインがついたURLにlink_toで指定する方法

Posted at

サブドメインが付いているURLをlink_toで指定する方法です。
業務の中で、サブドメインの異なるページからlink_toを用いて画面遷移する必要があったのでメモとして。

サブドメインが同じページからの遷移(通常)

= link_to "タスク一覧", tasks_path # 「tasks_path」の指定の仕方でOK

サブドメインの異なるページからの遷移

= link_to "タスク一覧", tasks_url(subdomain: 'xxx') # 「tasks_path」の指定では遷移できないので「tasks_url」と記述しなければいけない

IDを伴うURLへの遷移(インスタンス変数を渡す場合)

= link_to "タスク詳細", task_url(@task, subdmain: 'xxx') # (インスタンス変数, subdomain: 'xxx')の形をとる
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