Returns an file upload input tag tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object). Additional options on the input tag can be passed as a hash with options. These options will be tagged onto the HTML as an HTML element attribute as in the example shown.
Examples
file_field(:user, :avatar) # => <input name="user[avatar]" type="file" /> file_field(:post, :attached, :accept => 'text/html') # => <input name="post[attached]" type="file" /> file_field(:attachment, :file, :class => 'file_input') # => <input name="attachment[file]" type="file" />
Source Code
# File action_view/helpers/form_helper.rb, line 366 def file_field(object_name, method, options = {}) InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_input_field_tag("file", options) end
<code/>and<pre/>for code samples.