2017-06-04 27 views
0

如何在我的Rails窗體中定義特定的Id?如何在Rails輸入中定義id

<%= c.text_field :description, {placeholder: "New comment", class: 'form-control', id: 'comment_text_bar#{post.id}'} %> 

我試過#{},或<%=%>但它不是在這種情況下工作

+1

解釋*不工作*。你有什麼錯誤嗎? – Pavan

+0

當我檢查我想要的代碼時,id = comment_text_bar#{post.id}而不是comment_text_bar23244 –

+0

與''comment_text_bar <%=post.id%>''相同嗎? – Pavan

回答

3

您應該使用雙引號(」「)串插。這應該工作

<%= c.text_field :description, {placeholder: "New comment", class: 'form-control', id: "comment_text_bar#{post.id}"} %> 
+1

感謝您的回答@Pavan –

相關問題