控制器中的变量语法

时间:2013-08-24 18:42:31

标签: ruby-on-rails

应该是一个简单的问题,但我是一个Rails新手,只是有点黑客攻击。在这个语法中添加变量的格式是什么?伪代码:

 $var = '<html>' . $var2 . '</html>';

除了红宝石......

class PdfController < ApplicationController

  def index
    @html = %Q{
      <html>
      VARIABLE
      </html>
    }
  end
end

1 个答案:

答案 0 :(得分:3)

您可以使用Ruby插值:

class PdfController < ApplicationController

  def index
    @html = %Q{
      <html>
      #{ VARIABLE }
      </html>
    }
  end
end