<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>mah666hhh</author_name>
  <author_url>https://blog.hatena.ne.jp/mah666hhh/</author_url>
  <blog_title>スリ飯屋MaLankaのフリーエンジニアな日々</blog_title>
  <blog_url>https://www.malanka.org/</blog_url>
  <categories>
    <anon>技術関連</anon>
    <anon>技術関連 - Rails</anon>
  </categories>
  <description>ymlファイルの中でerbを使い、 動的に値を取得してrakeタスクの引数にしようとしていた。 が、 erbを使った部分が文字列のままで渡ってきて、 上手くいかなかった。 ymlファイル例は下記。 # test.yml.erb - id: age: 18 *** こういう値が欲しいが、 #=&gt; [{ id: 1, age: 18 }] # こうなってしまう #=&gt; [{ id: , age: 18 }] rakeタスク例は下記。 # test.rake ***File処理部分のみ記載*** # args.yamlは対象のymlファイルのパス File.open(args.yaml, 'r') do |file_obj| # TODO: ここで上手く読み込めていない yaml = YAML.load(file_obj) # rakeタスクの引数に「yaml」を指定して実行 end 結論 ERB.newを使う。</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwww.malanka.org%2Fentry%2Ferb-in-yaml&quot; title=&quot;【Rails】ymlファイルの中でerbを使い、動的に値を取得してrakeタスクの引数にする - スリ飯屋MaLankaのフリーエンジニアな日々&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>https://cdn-ak.f.st-hatena.com/images/fotolife/m/mah666hhh/20201208/20201208215407.jpg</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2020-12-08 21:56:20</published>
  <title>【Rails】ymlファイルの中でerbを使い、動的に値を取得してrakeタスクの引数にする</title>
  <type>rich</type>
  <url>https://www.malanka.org/entry/erb-in-yaml</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
