LoginSignup
0
0

More than 5 years have passed since last update.

Railsでテンプレートに変数を渡す方法

Posted at

テンプレートに変数を渡す方法

複数のファイルから同じテンプレートファイルを読み込むときに、
それぞれの読み込みもとのファイルから異なる変数を値を渡したいとする

読み込みもとのファイル

test.html.erb
<%= render "test/form", url: test_path %>

部分テンプレート

読み込まれるpartialファイルでは特に何も定義せず、下記のように使えます

test/form.html.erb
<%= link_to "test", url %>
0
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
0
0