My user gives his university information through simple form as a parameter and sends it to the server.
<div class="col-xs-12 col-s-4 col-sm-4">
<%= simple_fields_for :users do |r| %>
<%= r.input :university, required: false, placeholder: "University", label: false %>
<% end %>
</div>
How can I titleize the param input the user gives me?
I tried
<%= r.input :university.titleize, required: false, placeholder: "University", label: false %>
but it's not working.
The first parameter on the input receives the user attribute for which to generate the input, so, it's not the place to chain the titleize
method.
What you can do is to modify the value sent, before saving the record, or any action you might perform. As an example, if you're sending the data to a create method, then you can modify it after creating the user, and saving it into the database, like:
def create
@user = User.new(user_params)
@user.university = @user.university.titleize
...