问题显示使用Ruby on Rails 3的'file_field'的'size'属性 [英] Problem showing the 'size' attribute for a 'file_field' using Ruby on Rails 3
问题描述
我正在使用Ruby on Rails 3,并且具有这样的形式:
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 %>
当我去查看页面源代码时,这是生成的HTML代码:
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">
表示没有'size'属性.
that means the 'size' attribute there isn't.
我在Firefox,Chrome和Safari上尝试过:输出相同,但似乎一切设置正确.
I tried on Firefox, Chrome and Safari: same output, but it seems to have everything set correctly.
这是与RoR3相关的问题吗?
Is it a problem related to RoR3?
推荐答案
我实际上发现故意在此处的Rails源代码中忽略了size属性:
I actually found that the size attribute is intentionally left out of the Rails source code here:
"to_input_field_tag(" file,options.update({:size => nil})"
"to_input_field_tag("file", options.update({:size => nil})"
不知道为什么,但是很高兴听到您找到了解决方法.
Don't know why but glad to hear you found a workaround.
这篇关于问题显示使用Ruby on Rails 3的'file_field'的'size'属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!