The view doesen't capitalize first_name and last_name. Both of them are stored in downcase inside the db. In the model I have the following getters either for first_name and last_name:
def first_name
string_to_return = read_attribute(:first_name)
return string_to_return.capitalize if string_to_return != nil && !string_to_return.strip.empty?
return "N/A"
So I expect that in the view the first_name appear capitalized, but instead, when I edit the profile it appears in downcase, I use a form_for, the code is the following:
<%= form_for(@profile, :url=>{:action=>'update'}, :html => {:multipart => true}) do |f| %>
<div class="field">
<%= f.label :first_name %><br />
<%= (f.text_field (:first_name)).capitalize %>
</div>
<div class="field">
<%= f.label :last_name %><br />
<%= (f.text_field (:last_name))%>
</div>
<%end%>
I tried all the combinations of parenthesis without success, I tried to use and not use the capitalize function in the view but the result it's always the same: DOWNCASE
Any suggestion ? Tnx
why are you storing in downcase only? is there a reason for this? if you really have to downcase in the backend, im assuming that you just want to capitalize in the front end. if that is the case, you don't need your capitalize function in your backend. it should be done in the FRONT END(since your reason for capitalizing is for aesthetics only)
That could easily be achieved in the css by:
input {
text-transform: capitalize;
}