0
如何在我的Rails窗體中定義特定的Id?如何在Rails輸入中定義id
<%= c.text_field :description, {placeholder: "New comment", class: 'form-control', id: 'comment_text_bar#{post.id}'} %>
我試過#{}
,或<%=%>
但它不是在這種情況下工作
如何在我的Rails窗體中定義特定的Id?如何在Rails輸入中定義id
<%= c.text_field :description, {placeholder: "New comment", class: 'form-control', id: 'comment_text_bar#{post.id}'} %>
我試過#{}
,或<%=%>
但它不是在這種情況下工作
您應該使用雙引號(」「)爲串插。這應該工作
<%= c.text_field :description, {placeholder: "New comment", class: 'form-control', id: "comment_text_bar#{post.id}"} %>
感謝您的回答@Pavan –
解釋*不工作*。你有什麼錯誤嗎? – Pavan
當我檢查我想要的代碼時,id = comment_text_bar#{post.id}而不是comment_text_bar23244 –
與''comment_text_bar <%=post.id%>''相同嗎? – Pavan