I am using Ruby on Rails 3 and I have a form like this:
<%= form_for(@user, ... ) do |f| %>
...
<%= f.file_field :avatar, :id => "test_id", :style => "display: block", :size => "13" %>
...
<% end %>
When I go to see the source of the page, this is the HTML code generated:
<input type="file" style="display: block;" name="user[avatar]" id="test_id">
that means the ‘size’ attribute there isn’t.
I tried on Firefox, Chrome and Safari: same output, but it seems to have everything set correctly.
Is it a problem related to RoR3?
I actually found that the size attribute is intentionally left out of the Rails source code here:
https://github.com/rails/rails/blob/75366cb82dc6fa4b3dada2a450dda18496f3eddd/actionpack/lib/action_view/helpers/form_helper.rb#L734
“to_input_field_tag(“file”, options.update({:size => nil})”
Don’t know why but glad to hear you found a workaround.