Search code examples
htmlruby-on-railsrubyinputfilefield

Writing a ruby file_field in html


<%= f.file_field :photo %>

How do I write this in html? I know that it's an input type="file" but how can I put in the :photo? I need to customise the field by writing it in html in rails.


Solution

  • f is the oject name, photo is the attribute name, so you have

    id="object_photo"
    name="object[photo]"
    
    <input type="file" size="20" name="object[photo]" id="object_photo">