Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

formtastic paperclip attribute detection generates wrong html #36

Closed
brainlag opened this Issue · 5 comments

2 participants

@brainlag

Html generated with autodetection:

<li id="model_field_input" class="string required">
     <label for=model_field">Field<abbr title="required">*</abbr></label>
     <input type="text" value="/field/original/missing.png" size="50" name="model[field]" id="model_field"/>
</li>

Html generated whenn forced to :file (:as => :file)


  • Field*

  • @justinfrench

    What's the actual name of the file upload field? Can we see the code you're using to get this output?

    You're getting a "string" input rather than a "file" input because Formtastic doesn't think this field is a file upload field. There's some rudimentary checking in there (see @@file_methods config option and the code around line 1025), but without knowing the name of the attribute and some more stuff about your model, I can't write a decent (failing) test.

    @brainlag

    I think i should mention that I use Ruby 1.9.1. Not sure if this makes a difference, but I tried to run the specs last night and 95% of all testcases were failing.

    @justinfrench

    Pasting in DM from brainlag so all info is one one place:

    I think Formtastic thinks it is a "file" because the input box it generates with some text filled in. See the value attribute of the input field.

    Model:

    class Map < ActiveRecord::Base
    has_many :replays

    has_attached_file :image
    validates_attachment_presence :image
    validates_presence_of :name
    

    end
    View:

    <% semantic_form_for :map, :html => {:multipart => true}, :url => maps_path do |form| %>
    <% form.inputs do -%>
    <%= form.input :name %>
    <%= form.input :image %>
    <% end -%>
    <% form.buttons do -%>

    <%= form.commit_button 'Create' %>
    <% end -%>
    <% end %>

    @brainlag

    ok, i found what is wrong

    when you use semantic_form_for you should pass an instance variable and not a symbol
    because if you use a symbol the autodedection breaks

    so it is all my fault

    @justinfrench

    good know nothing serious was broken!

    This issue was closed.
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Something went wrong with that request. Please try again.