2017-06-04 9 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

私が正しいコードを調べると、comment_text_bar23244の代わりにid = comment_text_bar#{post.id} –

+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 –

関連する問題