f.text_field class属性を指定
856 ワード
form_for中のf.text_fieldでclass属性を指定したい
http://railsdoc.com/references/text_field
railsリファレンスをみてみると classオプションはこのように指定すると書いてある
↓
<%= text_field :page, :name, :class = 'page_name' %>
しかし、これで指定するとSyntax Error unexected '=', expect '}'
となり、どうやら=あたりが怪しいらしい。
解決策
stackoverflowで調べてみると= ではなく =>とすることでclassオプションを指定できると書いてあったので
<%= text_field :page, :name, :class => 'page_name' %>
こう変更すると成功した
にしてもリファレンス間違い多すぎやろ........
Author And Source
この問題について(f.text_field class属性を指定), 我々は、より多くの情報をここで見つけました https://qiita.com/eyexx/items/10691b0558ca0d0353b3著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .