Tef*_*Ted 5 ruby string interpolation escaping
鉴于此代码:
has_many :foos, :finder_sql = <<-SQL
select * from foos where bars = #{id}
SQL
Run Code Online (Sandbox Code Playgroud)
该#{id}部分被过早插值.
我怎么逃避它?
mck*_*eed 12
在分隔符周围加上单引号:
has_many :foos, :finder_sql = <<-'SQL'
select * from foos where bars = #{id}
SQL
Run Code Online (Sandbox Code Playgroud)