How to change default generated code for rails form helpers?
Code…
<%= f.text_field :title, class: 'inputbox' %>
…generates…
<input id="post_title" name="post[title]" class="inputbox" type="text">
…but I would like that text_field without class argument generated code above by default.
I am using rails 3.2.
In order to get this behavior you will either have to overwrite the existing text field method or add a new method that does what you want. I would recommend the latter since you won’t be changing the existing behavior of a built-in Rails method.
Similar to another answer:
Then you would just change you view to use this instead: