0
insert_after :homepage_products do
"
<h1>Promotional Item</h1>
<% products=Product.find_by_sql('select * from products where id in (select product_id from products_taxons where taxon_id in (select id from taxons where name='Promotion'))') %>
<%= render 'shared/products', :products => products, :taxon => @taxon %>
"
end
会给这个错误
compile error
inline template:3: syntax error, unexpected tCONSTANT, expecting ')'
...m taxons where name='Promotion'))')
^
inline template:3: syntax error, unexpected ')', expecting kEND
...ons where name='Promotion'))')
^
这里的问题是此行
select * from products where id in (select product_id from products_taxons where taxon_id in (select id from taxons where name='Promotion')
的'
使用给语法错误 但如果我将其更改为它会看起来像这样
insert_after :homepage_products do
"
<h1>Promotional Item</h1>
<% products=Product.find_by_sql('select * from products where id in (select product_id from products_taxons where taxon_id in (select id from taxons where name="Promotion"))') %>
<%= render 'shared/products', :products => products, :taxon => @taxon %>
"
end
注意促销字是如何变成不同颜色的? ,因为它与前面的重叠"
是否有任何其他“特殊字符”,可以在这里使用?
还是有其他选择吗?