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
注意促銷字是如何變成不同顏色的? ,因爲它與前面的重疊"
是否有任何其他「特殊字符」,可以在這裏使用?
還是有其他選擇嗎?